Google Groups Home
Help | Sign in
Message from discussion State in CAL
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
megagu...@gmail.com  
View profile
 More options Nov 3 2007, 5:00 pm
From: megagu...@gmail.com
Date: Sat, 03 Nov 2007 14:00:10 -0700
Local: Sat, Nov 3 2007 5:00 pm
Subject: Re: State in CAL
On Nov 3, 1:47 am, "Joseph Wong" <Joseph.W...@businessobjects.com>
wrote:

> I've tried reproducing your problem with importing a Java class named
> test.Var as a foreign type in CAL, but have not encountered the out of
> bounds exception. Would you mind sending more details (to this mailing
> list) about how it failed for you? That would be much appreciated!

Below is a small CAL and Java example that that reproduces the bug. In
the ICE console just write "var (10 :: Int)". When I change the Java
package name to test.x it works fine.

ICE error:

Error while executing: Fatal Executor error.
Caused by: java.lang.StringIndexOutOfBoundsException: String index out
of range: -1,  Detail: String index out of range: -1

Stack trace:

java.lang.StringIndexOutOfBoundsException: String index out of range:
-1
        at java.lang.String.substring(String.java:1938)
        at
org.openquark.cal.internal.machine.lecc.CALToJavaNames.getModuleNameFromPac kageName(CALToJavaNames.java:
733)
        at
org.openquark.cal.internal.machine.lecc.CALClassLoader.findClass(CALClassLo ader.java:
287)
        at
org.openquark.cal.internal.machine.lecc.CALClassLoader.loadClass(CALClassLo ader.java:
467)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
        at org.openquark.cal_MyModule1.Var.f1S(Var.java)
        at org.openquark.cal_MyModule1.Iceruntarget.f(Iceruntarget.java)
        at org.openquark.cal.internal.runtime.lecc.RTFullApp$General
$_0.reduce(RTFullApp.java:225)
        at
org.openquark.cal.internal.runtime.lecc.RTResultFunction.unsynchronizedEval uate(RTResultFunction.java:
136)
        at
org.openquark.cal.internal.runtime.lecc.RTResultFunction.evaluate(RTResultF unction.java:
103)
        at
org.openquark.cal_MyModule1.Io__iceruntarget__0__0.f(Io__iceruntarget__0__0 .java)
        at org.openquark.cal.internal.runtime.lecc.RTFullApp$General
$_0.reduce(RTFullApp.java:225)
        at
org.openquark.cal.internal.runtime.lecc.RTResultFunction.unsynchronizedEval uate(RTResultFunction.java:
136)
        at
org.openquark.cal.internal.runtime.lecc.RTResultFunction.evaluate(RTResultF unction.java:
103)
        at org.openquark.cal_Cal_Core_Prelude.Id.f(Id.java)
        at
org.openquark.cal.internal.runtime.lecc.RTApplication.reduce(RTApplication. java:
156)
        at
org.openquark.cal.internal.runtime.lecc.RTResultFunction.unsynchronizedEval uate(RTResultFunction.java:
136)
        at
org.openquark.cal.internal.runtime.lecc.RTResultFunction.evaluate(RTResultF unction.java:
103)
        at
org.openquark.cal.internal.machine.lecc.Executor.exec(Executor.java:
173)
        at org.openquark.cal.ICE$FunctionRunThread.run(ICE.java:7226)
        at java.lang.Thread.run(Thread.java:619)

CAL source:
------------------------------------------------------------
module MyModule1;

import Cal.Core.Prelude using
    typeClass = Eq, Inputable, Outputable;
    typeConstructor = JObject, Unit;
    function = output, toCalValue;
    ;

data foreign unsafe import jvm public "test.Var"
   public JVar deriving Inputable, Outputable, Eq;

foreign unsafe import jvm "constructor test.Var" private jVar_new ::
JObject -> JVar;

data public Var a = private Var value :: !JVar deriving Inputable,
Outputable, Eq;

var :: a -> Var a;
var !value =
    Var (jVar_new $ output $ toCalValue value);
------------------------------------------------------------

Java source:
------------------------------------------------------------
package test;

public class Var {
        private Object value;

        public Var(Object v) {
                value = v;
        }

}

------------------------------------------------------------

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google