janino-compiler / janino

Janino is a super-small, super-fast Java™ compiler.
http://janino-compiler.github.io/janino
Other
1.25k stars 208 forks source link

AsserationError #181

Closed enexusde closed 1 year ago

enexusde commented 2 years ago

I get an AsserationError, this is my stacktrace:

    java.lang.AssertionError: uninitializedThis
            at org.codehaus.janino.CodeContext.popOperand(CodeContext.java:1413)
            at org.codehaus.janino.UnitCompiler.tryAssignmentConversion(UnitCompiler.java:11023)
            at org.codehaus.janino.UnitCompiler.assignmentConversion(UnitCompiler.java:10994)
            at org.codehaus.janino.UnitCompiler.invokeConstructor(UnitCompiler.java:8295)
            at org.codehaus.janino.UnitCompiler.compileGet2(UnitCompiler.java:5468)
            at org.codehaus.janino.UnitCompiler.access$9700(UnitCompiler.java:231)
            at org.codehaus.janino.UnitCompiler$15.visitNewClassInstance(UnitCompiler.java:4643)
            at org.codehaus.janino.UnitCompiler$15.visitNewClassInstance(UnitCompiler.java:4604)
            at org.codehaus.janino.Java$NewClassInstance.accept(Java.java:5560)
            at org.codehaus.janino.UnitCompiler.compileGet(UnitCompiler.java:4604)
            at org.codehaus.janino.UnitCompiler.compileGetValue(UnitCompiler.java:5729)
            at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:2419)
            at org.codehaus.janino.UnitCompiler.access$1500(UnitCompiler.java:231)
            at org.codehaus.janino.UnitCompiler$6.visitFieldDeclaration(UnitCompiler.java:1527)
            at org.codehaus.janino.UnitCompiler$6.visitFieldDeclaration(UnitCompiler.java:1523)
            at org.codehaus.janino.Java$FieldDeclaration.accept(Java.java:2847)
            at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:1523)
            at org.codehaus.janino.UnitCompiler.initializeInstanceVariablesAndInvokeInstanceInitializers(UnitCompiler.java:7746)
            at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:3462)
            at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:3218)
            at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:812)
            at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:977)
            at org.codehaus.janino.UnitCompiler.access$700(UnitCompiler.java:231)
            at org.codehaus.janino.UnitCompiler$2.visitMemberClassDeclaration(UnitCompiler.java:394)
            at org.codehaus.janino.UnitCompiler$2.visitMemberClassDeclaration(UnitCompiler.java:386)
            at org.codehaus.janino.Java$MemberClassDeclaration.accept(Java.java:1532)
            at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:386)
            at org.codehaus.janino.UnitCompiler.compileDeclaredMemberTypes(UnitCompiler.java:1329)
            at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:1040)
            at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:422)
            at org.codehaus.janino.UnitCompiler.access$600(UnitCompiler.java:231)
            at org.codehaus.janino.UnitCompiler$2.visitPackageMemberInterfaceDeclaration(UnitCompiler.java:393)
            at org.codehaus.janino.UnitCompiler$2.visitPackageMemberInterfaceDeclaration(UnitCompiler.java:386)
            at org.codehaus.janino.Java$PackageMemberInterfaceDeclaration.accept(Java.java:2071)
            at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:386)
            at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:359)
            at org.codehaus.janino.UnitCompiler.access$000(UnitCompiler.java:231)
            at org.codehaus.janino.UnitCompiler$1.visitCompilationUnit(UnitCompiler.java:333)
            at org.codehaus.janino.UnitCompiler$1.visitCompilationUnit(UnitCompiler.java:330)
            at org.codehaus.janino.Java$CompilationUnit.accept(Java.java:367)
            at org.codehaus.janino.UnitCompiler.compileUnit(UnitCompiler.java:330)
            at org.codehaus.janino.Compiler.compile(Compiler.java:262)
            ...
            at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
            at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.base/java.lang.reflect.Method.invoke(Method.java:567)
            at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
            at org.springframework.transaction.interceptor.TransactionInterceptor$$Lambda$603/0x00000000f582b388.proceedWithInvocation(Unknown Source)
            at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:295)
            at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
            at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
            at jdk.proxy5/jdk.proxy5.$Proxy106.handle(Unknown Source)
           ...
            at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
            at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.base/java.lang.reflect.Method.invoke(Method.java:567)
            at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
            at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:206)
            at jdk.proxy5/jdk.proxy5.$Proxy104.handle(Unknown Source)
           (...)

The method I execute have this signature:

void compile(Resource[] sourceResources) throws CompileException, IOException;

Please:

  1. Find a better throwable than error.
  2. Give the message a meaningful name.
aunkrig commented 2 years ago

Hey Peter,

greetings to Berlin! The exception you get does not indicate an error in the code that you are trying to compile, but an internal error in Janino which should never occur. That's why it is an AssertionError and not a CompileException.

A verbose message would not be helpful for you, because it would only refer to Janino's internals, like "Unexpected verification type "uninitializedThis" found on operand stack".

Much more helpful would be the code snippet that you attempt to compile, and causes the error. Can you please provide that? Most suitable a minimal JUnit test case that reproduces the problem.

Also the Janino version that you are using is not the latest. Which is it? Could you try updating to the very latest version in order to see whether the problem has already been fixed?

aunkrig commented 2 years ago

Seems like you are using version 3.1.4, 3.1.5 or 3.1.6.

enexusde commented 2 years ago

From what I can tell it is on janino 3.1.8. Ill try to create a unit-test. "java.lang.Error" should "indicates serious problems that a reasonable application should not try to catch.". If asserations are enabled (-ea flag) then (and only then) its reasonable to throw AsserationError's (idealy by the keyword assert).

aunkrig commented 2 years ago

Trust me, we do have a serious problems here that a reasonable application should not try to catch. But, again, in order to fix that I absolutely need the code that you attempt to compile.

And the stack trace was 100% not caused by Janino 3.1.8.

enexusde commented 2 years ago

Hm, if a user write wrong java-code you say the server must die? Could be used as a DOS attack. I think I better move away from janino.

aunkrig commented 2 years ago

As I said before:

"The exception you get does not indicate an error in the code that you are trying to compile, but an internal error in Janino which should never occur. That's why it is an AssertionError and not a CompileException."

So, do you want to help me find and fix the bug or not?

enexusde commented 2 years ago

Sure Ill help, as I said: "Ill try to create a unit-test.". But it is complicated because I changed a lot and have no version-control for untested sourcecode.