Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Cannot Reproduce
-
spifly-1.0.8
-
None
-
None
Description
On weaving a jar that contains a utility loading class like this (this example is an enum, but the same happens if it's a class, anonymous inner class, etc.):
public enum Loader { LOADER; public <S> S load(Class<S> type) { Iterator<S> services = ServiceLoader.load(type).iterator(); return services.hasNext() ? services.next() : null; } }
The weaving throws this exception:
java.lang.IllegalArgumentException: value null at org.objectweb.asm.ClassWriter.newConstItem(ClassWriter.java:1057) at org.objectweb.asm.MethodWriter.visitLdcInsn(MethodWriter.java:1126) at org.apache.aries.spifly.weaver.TCCLSetterVisitor$TCCLSetterMethodVisitor.visitMethodInsn(TCCLSetterVisitor.java:194) at org.objectweb.asm.ClassReader.readCode(ClassReader.java:1416) at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1017) at org.objectweb.asm.ClassReader.accept(ClassReader.java:693) at org.objectweb.asm.ClassReader.accept(ClassReader.java:506) at org.apache.aries.spifly.statictool.Main.weaveDir(Main.java:196) at org.apache.aries.spifly.statictool.Main.weaveJar(Main.java:96) at org.apache.aries.spifly.statictool.Main.main(Main.java:73) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:282) at java.lang.Thread.run(Thread.java:745)
This happens regardless of whether static or dynamic weaving is used.
I'll attach a sample project.