Menu

#49 Janino 2.0 throwing exception on arrays of java.io.File

closed-fixed
5
2004-04-11
2004-04-07
No

I isolated the problem using the ScriptDemo example.
The modified version I used should be attached to this
message.

On a possibly related note, this seems to be exactly
the same message that Janino was giving off under java
1.5 (only the stack trace was different). The
exception seems to be happening in the same place.

Here is what "java -version" prints out:
java version "1.4.2_03"
Java(TM) 2 Runtime Environment, Standard Edition (build
1.4.2_03-b02)
Java HotSpot(TM) Client VM (build 1.4.2_03-b02, mixed mode)

Janino 2.0 is giving this stack trace on an attempt to
compile a script that uses an array of java.io.File
objects:

Exception in thread "main" java.lang.RuntimeException:
S.N.O.: Cannot determine array type of "java.io.File"
at
net.janino.IClassLoader.loadArrayIClass(Unknown Source)
at net.janino.Java.getArrayType(Unknown Source)
at net.janino.Java.access$4500(Unknown Source)
at net.janino.Java$ArrayType.getType(Unknown
Source)
at
net.janino.Java$LocalVariableDeclarationStatement.compile(Unknown
Source)
at net.janino.Java$Block.compile(Unknown Source)
at
net.janino.Java$FunctionDeclarator.compile(Unknown Source)
at
net.janino.Java$ClassDeclaration.compile(Unknown Source)
at
net.janino.Java$CompilationUnit.compile(Unknown Source)
at
net.janino.Java$CompilationUnit.compile(Unknown Source)
at
net.janino.EvaluatorBase.compileAndLoad(Unknown Source)
at
net.janino.EvaluatorBase.compileAndLoad(Unknown Source)
at net.janino.ScriptEvaluator.<init>(Unknown
Source)
at net.janino.ScriptEvaluator.<init>(Unknown
Source)
at net.janino.ScriptEvaluator.<init>(Unknown
Source)
at net.janino.ScriptEvaluator.<init>(Unknown
Source)
at net.janino.ScriptEvaluator.<init>(Unknown
Source)
at ScriptDemo.main(ScriptDemo.java:95)

Discussion

  • Richard Owen Lewis

    Only modified this file to change the default script.

     
  • Arno Unkrig

    Arno Unkrig - 2004-04-11

    Logged In: YES
    user_id=865893

    These were two bugs:

    (A)
    A Janino bug: "Descriptor.toClassName()" handled array
    types wrong (e.g. "[Ljava/lang/String;" was converted to
    "java.lang.String[]" instead of "[Ljava.lang.String;").
    Amazing that this bug only crashed the ScriptDemo!?

    (B)
    An (obvious) JDK 1.5.0 beta bug: There are two ways to load
    a class: "Class.forName()" and "ClassLoader.loadClass()".
    The JDK documentation does not say it clearly, but these two
    should be equivalent, and to my best knowledge are. EXCEPT:
    "ClassLoader.loadClass("[Ljava.lang.String;")" throws a
    ClassNotFoundException under JDK 1.5.0 beta. For non-array
    types it works, and also for array types under JDKs 1.2.2,
    1.3, 1.4.1. The solution is to user "Class.forName()" which
    seems to work under ALL JDKs and for ALL types, including
    array types. Weird.

    Fixed in release 2.0.1

     
  • Arno Unkrig

    Arno Unkrig - 2004-04-11
    • status: open --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB