Version: 2.0.13
Example:
---
public class Silly
{
public static void main(String[] args)
{
int x=5;
System.out.println("1:"+x);
silly(x*=2); //d'oh
System.out.println("3:"+x);
}
public static void silly(int x)
{
System.out.println("2:"+x);
}
}
################################
[1]Compilation fails with JavaSourceClassLoader
################################
Compile/run with:
java -cp .;janino.jar net.janino.JavaSourceClassLoader
Silly
---
Throws exception:
Exception in thread "main"
net.janino.util.TunnelException caused by:
net.janino.Java$CompileException: File .\Silly.java,
Line 7, Column 10: Operator"*=" as an rvalue NYI
at net.janino.Java.compileError(Java.java:8750)
at net.janino.Java.access$100(Java.java:51)
at net.janino.Java$Located.compileError(Java.java:98)
at net.janino.Java$Assignment.compileGet(Java.java:5276)
at net.janino.Java$Rvalue.compileGetValue(Java.java:4003)
at
net.janino.Java$MethodInvocation.compileGet(Java.java:6850)
at net.janino.Java$Rvalue.compileGetValue(Java.java:4003)
at net.janino.Java$Rvalue.compile(Java.java:3986)
at
net.janino.Java$ExpressionStatement.compile(Java.java:2486)
at net.janino.Java$Block.compile(Java.java:2364)
at
net.janino.Java$FunctionDeclarator.compile(Java.java:1673)
at net.janino.Java$ClassDeclaration.compile(Java.java:829)
at net.janino.Java$CompilationUnit.compile(Java.java:361)
at net.janino.Java$CompilationUnit.compile(Java.java:350)
at
net.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:255)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at
net.janino.JavaSourceClassLoader.main(JavaSourceClassLoader.java:145)
#########################################
[2]Compilation doesn't fail with net.janino.Compiler,
but the result is wrong
#########################################
java -cp .;janino.jar net.janino.Compiler -verbose -g
-rebuild Silly.java
"Warning" message:
File Silly.java, Line 7, Column 10: Operator"*=" as an
rvalue NYI
Running the class results in:
1:5
2:2
3:2
----
Ok. No one uses that. However, it's valid syntax and
it's output should be:
1:5
2:10
3:10
---
But there is even more...
If you're wondering why I'm *trying* such odd stuff...
it was a mistake... introduced by some refactoring. And
it took me hours to track it down, because it wasn't in
the "main" class (some class B used in class A; where A
is the entry point for the compilation).
It took me that long, because I thought the compilation
was successfull (the A class wasn't null and no
exception was thrown... I just started it... and it
worked fine... printing silly debug messages up to the
point were I instanciated B).
So, while I'm at it. It would be sweet (and maybe more
important than fixing this little bug) if some
exception is thrown when compiling of one or more
classes fails.
[Btw thanks for this nice piece of tech ;)]
Logged In: YES
user_id=865893
Well, as the stack trace says:
Operator"*=" as an rvalue NYI
So this is actually a feature request, not a bug ;-)
Anyway, I just added the feature; will be realeased with
version 2.0.15.
Logged In: YES
user_id=678669
Great! :)
Logged In: YES
user_id=865893
The problem with the warning message is that JANINO attempts
to continue compilation if at all possible after a
compilation error. Unfortunately, it continues to store the
generated class files even after compilation errors have
occurred.
Would you be so kind and write another Bug report indicating
that?
Logged In: YES
user_id=678669
>Would you be so kind and write another Bug report indicating
that?
Uhm... the latest bug, I submitted "[ 1061120 ] SomeClass
s=new SomeClass; gets compiled" is kinda like that, right?