The Janino compiler doesn't detect uninitialized
variables and happily generates code for them, which
causes verify errors on classload. Simple example:
public class Bug
{
public static void main(String [] args)
{
java.lang.String s;
if (args.length > 2) {
s = "hello, world";
} else {
}
System.out.println(s);
}
}
Here's the output from janino-2.2.0:
Exception in thread "main" java.lang.VerifyError:
(class: Bug, method: main signature:
([Ljava/lang/String;)V) Accessing value from
uninitialized register 1
at java.lang.Class.getDeclaredMethods0(Native
Method)
at
java.lang.Class.privateGetDeclaredMethods(Class.java:1647)
at java.lang.Class.getMethod0(Class.java:1893)
at java.lang.Class.getMethod(Class.java:976)
at
org.codehaus.janino.JavaSourceClassLoader.main(Unknown
Source)
Logged In: YES
user_id=865893
JANINO does not check "definite assignment" (JLS2 16).
Checking of definite assignment is difficult to implement,
which is why I leave it to the JVM ;-) JANINO is intended
for "embedded" applications and is NOT a reference
implementation of a Java compiler.
I'll document JANINO's behavior in the "limitations" section
in the JAVADOC of "Parser".