CalebFenton/simplify

Error running demoapp fatjar

Closed this issue · 2 comments

Hi here,

I try to run demoapp in single mode. To do it I use the following changes on build.gradle file (inside demoapp folder) :

project.version = '1.0.0''
apply plugin: 'java''
//mainClassName = 'org.cf.demoapp.Main'
task fatJar(type: Jar) {'
manifest {
attributes 'Implementation-Title': 'Gradle Jar File Example',
'Implementation-Version': version,
'Main-Class': 'org.cf.demoapp.Main'
}'
baseName = project.name'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
dependencies {
compile project(':smalivm')
compile depends.slf4j_api'
compile depends.slf4j_nop'
testCompile depends.junit'
}

I build it as follows:

gradle fatjar
:smalivm:compileJava UP-TO-DATE
:smalivm:processResources UP-TO-DATE
:smalivm:classes UP-TO-DATE
:smalivm:jar UP-TO-DATE
:demoapp:compileJava UP-TO-DATE
:demoapp:processResources NO-SOURCE
:demoapp:classes UP-TO-DATE
:demoapp:fatJar

BUILD SUCCESSFUL

Total time: 15.316 secs

When I run it :

java -jar build/libs/demoapp-1.0.0.jar
Creating class manager with this path: /home/xxx/simplify/demoapp/resources (2)
java.lang.IllegalAccessException: Class org.cf.smalivm.emulate.MethodEmulator can not access a member of class org.cf.demoapp.java_io_PrintStream_println with modifiers ""
at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:102)
at java.lang.Class.newInstance(Class.java:436)
at org.cf.smalivm.emulate.MethodEmulator.getMethod(MethodEmulator.java:58)
at org.cf.smalivm.emulate.MethodEmulator.(MethodEmulator.java:33)
at org.cf.smalivm.opcode.InvokeOp.executeNonLocalMethod(InvokeOp.java:417)
at org.cf.smalivm.opcode.InvokeOp.execute(InvokeOp.java:99)
at org.cf.smalivm.context.ExecutionNode.execute(ExecutionNode.java:52)
at org.cf.smalivm.NodeExecutor.execute(NodeExecutor.java:77)
at org.cf.smalivm.MethodExecutor.execute(MethodExecutor.java:62)
at org.cf.smalivm.VirtualMachine.execute(VirtualMachine.java:103)
at org.cf.smalivm.VirtualMachine.execute(VirtualMachine.java:82)
at org.cf.smalivm.opcode.InvokeOp.executeLocalMethod(InvokeOp.java:335)
at org.cf.smalivm.opcode.InvokeOp.execute(InvokeOp.java:136)
at org.cf.smalivm.context.ExecutionNode.execute(ExecutionNode.java:52)
at org.cf.smalivm.NodeExecutor.execute(NodeExecutor.java:77)
at org.cf.smalivm.MethodExecutor.execute(MethodExecutor.java:62)
at org.cf.smalivm.VirtualMachine.execute(VirtualMachine.java:103)
at org.cf.smalivm.VirtualMachine.execute(VirtualMachine.java:64)
at org.cf.smalivm.VirtualMachine.execute(VirtualMachine.java:54)
at org.cf.demoapp.Main.main(Main.java:31)
Exception in thread "main" java.lang.RuntimeException: Real exception was thrown executing >> ExecutionNode{signature=Lorg/cf/demosmali/Main;->main([Ljava/lang/String;)V, op=invoke-static >> {}, Lorg/cf/demosmali/Main;->helloWorld()V} and was not handled. This could be a bug in smalivm.
Exception: java.lang.RuntimeException: Real exception was thrown executing ExecutionNode{signature=Lorg/cf/demosmali/Main;->helloWorld()V, op=invoke-virtual {r2, r3}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V} and was not handled. This could be a bug in smalivm.
Exception: java.lang.NullPointerException
at org.cf.smalivm.NodeExecutor.execute(NodeExecutor.java:88)
at org.cf.smalivm.MethodExecutor.execute(MethodExecutor.java:62)
at org.cf.smalivm.VirtualMachine.execute(VirtualMachine.java:103)
at org.cf.smalivm.VirtualMachine.execute(VirtualMachine.java:64)
at org.cf.smalivm.VirtualMachine.execute(VirtualMachine.java:54)
at org.cf.demoapp.Main.main(Main.java:31)

Maybe I'm doing something wrong, I'm totally new from gradle.

I just want to build a jar using smalivm tool as you did with your example.
I did not modify any file an ressources/ folder is in the folder from where I call the command (2).

Have you got an idea of what happens here ?

Thanks you !

Thanks for pointing this out. I never give demoapp enough love and it never occurred to me to add a fatjar task for it. It's been added now so you should be able to gradle fatjar without any modification.

Also, the error was caused by org.cf.demoapp.java_io_PrintStream_println's constructor was package private. All of the other emulated classes are package private because they sit with the class which calls them. It's been fixed (along with fatjar task added) in 64df0d7.

Woo thanks for your reactivity !
I'll try this soon.
Cheer!