asm issueshttps://gitlab.ow2.org/asm/asm/-/issues2017-12-26T09:14:58Zhttps://gitlab.ow2.org/asm/asm/-/issues/316188ASM fails to load a class file with ClassCircularityError2017-12-26T09:14:58ZjamesssssASM fails to load a class file with ClassCircularityError```
If you have a class that implements an interface and has a method that assign
itself to a variable of type the interface, ASM fails to load the class with a
ClassCircularityError
Occurs with ASM 3.3.1 and JDK 1.6
``````
If you have a class that implements an interface and has a method that assign
itself to a variable of type the interface, ASM fails to load the class with a
ClassCircularityError
Occurs with ASM 3.3.1 and JDK 1.6
```https://gitlab.ow2.org/asm/asm/-/issues/316181ASM throws ArrayIndexOutOfBoundsException while parsing class file2017-12-26T10:35:50Zm_holzhaASM throws ArrayIndexOutOfBoundsException while parsing class file```
Hi,
when reading the attached class file with the following simple commands, ASM
3.3.1 throws an ArrayIndexOutOfBoundsException:
InputStream inputStream = new BufferedInputStream(new
FileInputStream("LittleExamples.class"));
Cl...```
Hi,
when reading the attached class file with the following simple commands, ASM
3.3.1 throws an ArrayIndexOutOfBoundsException:
InputStream inputStream = new BufferedInputStream(new
FileInputStream("LittleExamples.class"));
ClassReader reader = new ClassReader(inputStream);
ClassNode node = new ClassNode();
reader.accept(node, 0);
```https://gitlab.ow2.org/asm/asm/-/issues/312691asm-3.1.jar is missing packages2017-12-26T10:53:28Zdstaraasm-3.1.jar is missing packages```
I downloaded asm-3.1.jar and found that it was missing the following packages:
org.objectweb.asm.attrs
org.objectweb.asm.commons
org.objectweb.asm.optimizer
org.objectweb.asm.tree
org.objectweb.asm.util
org.objectweb.asm.xml
To rep...```
I downloaded asm-3.1.jar and found that it was missing the following packages:
org.objectweb.asm.attrs
org.objectweb.asm.commons
org.objectweb.asm.optimizer
org.objectweb.asm.tree
org.objectweb.asm.util
org.objectweb.asm.xml
To reproduce:
* Navigate to http://www.ow2.org/
* From Go to project: dropdown, select ASM
* From the asm-jar version 3.1 row, click on Download
* Under asm-jar, click on asm-3.1.jar
* Click http download from France
* View contents of jar
Expected result:
The classes in org.objectweb.asm are in the jar along with the packages listed
above and org.objectweb.asm.signature
Actual result:
The classes and signature pack are present, but not the packages listed above
```https://gitlab.ow2.org/asm/asm/-/issues/312317MethodVisitor JavaDoc is incorrect2017-12-26T10:54:08ZcdennisMethodVisitor JavaDoc is incorrect```
The MethodVisitor javadoc documents restrictions on the visiting order for
try/catch block and label visits that no longer apply.
``````
The MethodVisitor javadoc documents restrictions on the visiting order for
try/catch block and label visits that no longer apply.
```https://gitlab.ow2.org/asm/asm/-/issues/312029CheckClassAdapter:verify should allow for a custom classloader2017-12-26T10:54:39ZrhuddusaCheckClassAdapter:verify should allow for a custom classloader```
We need to run verify in a custom classloader but deep inside the code
(SimpleVerifier) there is a call to Class.forName() which uses the classloader
from the calling class. So we would need to load asm in our custom
classloader,...```
We need to run verify in a custom classloader but deep inside the code
(SimpleVerifier) there is a call to Class.forName() which uses the classloader
from the calling class. So we would need to load asm in our custom
classloader, which is not what we want to do because it pollutes our
classloader.
We tried to copy the code from verify, but there are some package protected
variables we can't access. So that is a no go.
So two possible solutions. Fix the verify code so that it can be copied out
and not access any package / private stuff. Or add another verify method
which takes a custom classloader.
Also, might also add this functionality to the SimpleVerifier. Allow it to be
created with a custom class loader.
```https://gitlab.ow2.org/asm/asm/-/issues/315942asm-xml.dtd fails to mention SWAP element2017-12-26T10:37:19Zseweasm-xml.dtd fails to mention SWAP element```
Although the <SWAP> element is generated by
org.objectweb.asm.xml.SAXCodeAdapter.visitInsn, the corresponding DTD fails to
mention this fact.
``````
Although the <SWAP> element is generated by
org.objectweb.asm.xml.SAXCodeAdapter.visitInsn, the corresponding DTD fails to
mention this fact.
```https://gitlab.ow2.org/asm/asm/-/issues/312001AnnotationVisitor visitArray - for annotation array with no name should not a...2017-12-26T10:55:01ZthelaurgAnnotationVisitor visitArray - for annotation array with no name should not append '='```
I can not get to an annotation like:
@XmlElements({ @XmlElement(type=Integer.class, name="A"),
@XmlElement(type=Float.class, name="B"),
@XmlElement(type=int.class, name="C")
})
becau...```
I can not get to an annotation like:
@XmlElements({ @XmlElement(type=Integer.class, name="A"),
@XmlElement(type=Float.class, name="B"),
@XmlElement(type=int.class, name="C")
})
because in the best case I get:
@XmlElements(={ @XmlElement(type=Integer.class, name="A"),
@XmlElement(type=Float.class, name="B"),
@XmlElement(type=int.class, name="C")
})
I need to annotate a field having the above annotation as target.
but when I try to do the array {...} I have no possibility to remove
the "arrayName"={...} from the annotation. If I give visitArray an empty string
as parameter the = will remain in annotation.
```https://gitlab.ow2.org/asm/asm/-/issues/315135COMPUTE_FRAMES with CheckClassAdapter gives IndexOutOfBoundsException2018-01-21T09:34:20ZapmckinlayCOMPUTE_FRAMES with CheckClassAdapter gives IndexOutOfBoundsException```
This code:
public Object call(Object self, Object... args) {
return null;
}
run through Bytecode Outline, and then edited slightly to get:
import org.objectweb.asm.*;
import org.objectweb.asm.util.CheckClassAdapter;
public cl...```
This code:
public Object call(Object self, Object... args) {
return null;
}
run through Bytecode Outline, and then edited slightly to get:
import org.objectweb.asm.*;
import org.objectweb.asm.util.CheckClassAdapter;
public class TestAsm implements Opcodes {
public static void main(String[] args) throws Exception {
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
ClassVisitor cv = new CheckClassAdapter(cw);
MethodVisitor mv;
cv.visit(V1_6, ACC_PUBLIC + ACC_SUPER, "suneido/language/SampleFunction",
null, "suneido/language/SuFunction", null);
mv = cv.visitMethod(ACC_PUBLIC + ACC_VARARGS, "call",
"(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;", null, null);
mv.visitCode();
Label l0 = new Label();
mv.visitLabel(l0);
mv.visitInsn(ACONST_NULL);
mv.visitInsn(ARETURN);
Label l3 = new Label();
mv.visitLabel(l3);
mv.visitLocalVariable("this", "Lsuneido/language/SampleFunction;", null, l0, l3, 0);
mv.visitLocalVariable("self", "Ljava/lang/Object;", null, l0, l3, 1);
mv.visitLocalVariable("args", "[Ljava/lang/Object;", null, l0, l3, 2);
mv.visitMaxs(0, 0);
mv.visitEnd();
cv.visitEnd();
}
}
gives:
java.lang.IndexOutOfBoundsException: Trying to access an inexistant local variable 0
at org.objectweb.asm.tree.analysis.Frame.setLocal(Unknown Source)
at org.objectweb.asm.tree.analysis.Analyzer.analyze(Unknown Source)
at org.objectweb.asm.util.CheckMethodAdapter$1.visitEnd(Unknown Source)
at org.objectweb.asm.util.CheckMethodAdapter.visitEnd(Unknown Source)
at suneido.language.TestAsm.main(TestAsm.java:29)
Exception in thread "main" java.lang.RuntimeException: Trying to access an inexistant local variable 0
call(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
00000 ? : L0
00001 ? : ACONST_NULL
00002 ? : ARETURN
00003 ? : L1
at org.objectweb.asm.util.CheckMethodAdapter$1.visitEnd(Unknown Source)
at org.objectweb.asm.util.CheckMethodAdapter.visitEnd(Unknown Source)
at suneido.language.TestAsm.main(TestAsm.java:29)
If I turn off data flow checking it works.
With visitMaxs(1, 3) or visitMaxs(99, 99) it works (with or without COMPUTE_FRAMES)
Is it possible to use CheckClassAdapter with COMPUTE_FRAMES?
My apologies in advance if I'm doing something stupid. I've searched but couldn't find an answer.
```https://gitlab.ow2.org/asm/asm/-/issues/311642StackOverflowException in Label.visitSubroutine2018-01-20T11:28:53ZgpothierStackOverflowException in Label.visitSubroutine```
I get a stack overflow on a specific class with the attached program using ASM
3.1. What seems to trigger this is the visitLabel in MyMethodVisitor:22,
removing this line removes the error.
Excerpt of stack trace:
Exception in threa...```
I get a stack overflow on a specific class with the attached program using ASM
3.1. What seems to trigger this is the visitLabel in MyMethodVisitor:22,
removing this line removes the error.
Excerpt of stack trace:
Exception in thread "main" java.lang.StackOverflowError
at org.objectweb.asm.Label.visitSubroutine(Label.java:499)
at org.objectweb.asm.Label.visitSubroutine(Label.java:508)
at org.objectweb.asm.Label.visitSubroutine(Label.java:508)
```https://gitlab.ow2.org/asm/asm/-/issues/309819GeneratorAdapter has a typo in2017-12-26T10:57:31ZericzundelGeneratorAdapter has a typo in```
Here on the GWT project we had a test case fail which we traced back to
using the GeneratorAdapter class for passing character arguments to a method
and found a typo in the push() method for case Type.CHAR.
java/lang/Char should...```
Here on the GWT project we had a test case fail which we traced back to
using the GeneratorAdapter class for passing character arguments to a method
and found a typo in the push() method for case Type.CHAR.
java/lang/Char should have been java/lang/Character at line 410.
(In the future, using constant or enum values might prevent this type of error.)
```https://gitlab.ow2.org/asm/asm/-/issues/309037GeneratorAdapter generates jump instructions wrongly2018-02-11T15:32:03ZshevekGeneratorAdapter generates jump instructions wrongly```
From the end of GeneratorAdapter.ifCmp(...)
int jumpMode = mode;
switch (mode) {
case GE:
jumpMode = LT;
break;
case LE:
jumpMode = GT;
...```
From the end of GeneratorAdapter.ifCmp(...)
int jumpMode = mode;
switch (mode) {
case GE:
jumpMode = LT;
break;
case LE:
jumpMode = GT;
break;
}
I can't tell why this is done at all, because as far as I can tell, it makes
the jump come out wrong. If I do ifCmp(INT_TYPE, GE, label), I get an
IF_ICMPGE. If I do a ifCmp(LONG_TYPE, GE, label), I get LCMP; IFLT, which is
wrong. I want IFGE, which is what I asked for.
I also think that the choice of DCMPG/DGMPL should be made so that the jump is
executed on NaN (consider the common case), or at least, this should be
specifiable.
```https://gitlab.ow2.org/asm/asm/-/issues/309689ArrayIndexOutOfBoundsException in ASM2017-12-26T10:57:48ZmheveryArrayIndexOutOfBoundsException in ASM```
java.lang.ArrayIndexOutOfBoundsException: 0
at org.objectweb.asm.ClassReader.readClass(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at com.google....```
java.lang.ArrayIndexOutOfBoundsException: 0
at org.objectweb.asm.ClassReader.readClass(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at com.google.test.metric.ClassRepositoryTest.testClover12(ClassRepositoryTest.java:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:76)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Here is code to reproduce this:
public void testClover12() throws Exception {
URLClassLoader cl = new URLClassLoader(new URL[]{new
URL("http://mirrors.ibiblio.org/pub/mirrors/maven2/clover/clover/1.2/clover-1.2.jar")});
ClassReader classReader = new
ClassReader(cl.getResourceAsStream("com/cortexeb/tools/clover/ll.class"));
ClassVisitor visitor = new NoopClassVisitor();
try {
classReader.accept(visitor, 0);
} catch (ArrayIndexOutOfBoundsException e) {
// We should never get here!
e.printStackTrace();
fail(e.getMessage());
}
}
```https://gitlab.ow2.org/asm/asm/-/issues/315096ASM transforms LDC_W instructions to LDC2017-12-26T10:43:06ZcowwocASM transforms LDC_W instructions to LDC```
Repro steps:
1) Compile this testcase:
public class Testcase
{
public static void main(String[] args)
{
Class<?> c = Testcase.class;
}
}
2) javap -c -p Testcase.class gives:
public class Testcase extends java.lang.Objec...```
Repro steps:
1) Compile this testcase:
public class Testcase
{
public static void main(String[] args)
{
Class<?> c = Testcase.class;
}
}
2) javap -c -p Testcase.class gives:
public class Testcase extends java.lang.Object {
public Testcase();
Code:
0: aload_0
1: invokespecial #9 // Method java/lang/Object."<init>":
()V
4: return
public static void main(java.lang.String[]);
Code:
0: ldc_w #2 // class Testcase
2: astore_1
3: return
}
3) Process the class using ASM 3.3 as follows:
BufferedInputStream in = new BufferedInputStream(new FileInputStream(inputFile));
ClassReader classReader = new ClassReader(in);
BufferedOutputStream out = new BufferedOutputStream(new
FileOutputStream(outputFile));
ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS);
classReader.accept(classWriter, 0);
out.write(classWriter.toByteArray());
out.close();
4) javap -c -p Testcase.class now gives:
public class Testcase extends java.lang.Object {
public Testcase();
Code:
0: aload_0
1: invokespecial #9 // Method java/lang/Object."<init>":
()V
4: return
public static void main(java.lang.String[]);
Code:
0: ldc #2 // class Testcase
2: astore_1
3: return
}
5) Notice that the LDC_W instruction in the main() method was transformed into
a LDC.
```https://gitlab.ow2.org/asm/asm/-/issues/311100patch to make verifying multiple classes easier2017-12-26T10:56:30Zcolinwalterspatch to make verifying multiple classes easier```
Hi, for my project I am generating a lot of interdependent classes. The ASM
CheckClassAdapter can verify a single class well enough, but it uses
SimpleVerifier which just calls Class.forName to load dependencies, and this is
not con...```
Hi, for my project I am generating a lot of interdependent classes. The ASM
CheckClassAdapter can verify a single class well enough, but it uses
SimpleVerifier which just calls Class.forName to load dependencies, and this is
not convenient if one wants to verify the classes in the same process since
they won't be on the CLASSPATH normally. The attached patch allows one to
specify a ClassLoader to use to load dependencies.
```https://gitlab.ow2.org/asm/asm/-/issues/311075Duplicate in methodNode.localVariables2017-12-26T10:56:46ZevernatDuplicate in methodNode.localVariables```
In asm 3.1 when read with ClassNode, it seems that the following class causes a
duplicate of the localVariableNode "s" in the list methodNode.localVariables
(i.e. 2 instances of LocalVariableNode in the list with same name and same i...```
In asm 3.1 when read with ClassNode, it seems that the following class causes a
duplicate of the localVariableNode "s" in the list methodNode.localVariables
(i.e. 2 instances of LocalVariableNode in the list with same name and same index).
The class :
public class Test {
public void test() {
final String s;
if (Math.abs(0) < 1) {
s = "t";
} else {
s = "f";
}
}
}
ClassNode is used like this :
final ClassNode classNode = new ClassNode();
final ClassReader classReader = new ClassReader(...);
classReader.accept(classNode, ClassReader.EXPAND_FRAMES);
I can filter local variables based on indexes, but it was a surprise to have
duplicates.
PS: I'm trying to detect dead local variables in a static analysis program :
http://dcd.dev.java.net
```https://gitlab.ow2.org/asm/asm/-/issues/308875ClassWriter COMPUTE_MAXS produces invalid class (verify error)2017-12-26T10:59:16ZteckClassWriter COMPUTE_MAXS produces invalid class (verify error)```
The input class is silly for sure, but is a valid class produced by sun javac.
Running the test program should get this verifier error:
Exception in thread "main" java.lang.VerifyError: (class: Foo, method: main
signature: ([Ljava/l...```
The input class is silly for sure, but is a valid class produced by sun javac.
Running the test program should get this verifier error:
Exception in thread "main" java.lang.VerifyError: (class: Foo, method: main
signature: ([Ljava/lang/String;)V) Stack size too large
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
at java.lang.Class.getConstructor0(Class.java:2699)
at java.lang.Class.newInstance0(Class.java:326)
at java.lang.Class.newInstance(Class.java:308)
at Test.main(Test.java:18)
If you compile the Foo class with eclipse I don't think the problem will
happen. I used javac from sun's jdk1.5.0_15 on windows.
Looking at javap_output.txt for the original and out output bytes, it looks
like the max stack is getting calculated to be 0 even though the exception
block (which can't execute) does push something on the stack.
No patch for you this time, sorry. Maybe later
```https://gitlab.ow2.org/asm/asm/-/issues/315882java.lang.ClassFormatError: Invalid this class index 4099 in constant pool in...2017-12-26T10:37:52Zxpoinsardjava.lang.ClassFormatError: Invalid this class index 4099 in constant pool in class file```
I am trying to generate a big class with many String constants.
It seems that something went wrong with the constant pool.
I joined the output of the TraceClassVisitor and the generated bytecode.
``````
I am trying to generate a big class with many String constants.
It seems that something went wrong with the constant pool.
I joined the output of the TraceClassVisitor and the generated bytecode.
```https://gitlab.ow2.org/asm/asm/-/issues/309051AdviceAdapter throw and catch withing the same method2017-12-26T10:58:13Zakull82AdviceAdapter throw and catch withing the same method```
Hello,
the AdviceAdapter is super to include tracing into an method,
but if the method contains code like
try {
if( checkSomething() )
throw new Exception();
} catch( Exception e ) {
Log.err( e );
throw e;
}
the o...```
Hello,
the AdviceAdapter is super to include tracing into an method,
but if the method contains code like
try {
if( checkSomething() )
throw new Exception();
} catch( Exception e ) {
Log.err( e );
throw e;
}
the onMethodExit is called two times.
and I think something like
try {
return 1;
} finally {
throw new Exception();
}
should failed too.
```https://gitlab.ow2.org/asm/asm/-/issues/309040GeneratorAdapter box() should use Integer.valueOf()2017-12-26T10:58:26ZshevekGeneratorAdapter box() should use Integer.valueOf()```
Integer.valueOf() and Long.valueOf(), etc use an object cache to reduce memory
usage, they are the preferred way of boxing numbers to "new Integer(...)".
Please can GeneratorAdapter.box() use these methods?
S.
``````
Integer.valueOf() and Long.valueOf(), etc use an object cache to reduce memory
usage, they are the preferred way of boxing numbers to "new Integer(...)".
Please can GeneratorAdapter.box() use these methods?
S.
```https://gitlab.ow2.org/asm/asm/-/issues/315864byte code transformation corrupts classes2017-12-26T10:38:34Zfdabyte code transformation corrupts classes```
Hello,
working with the ASM library I bumped into strange issue, the trivial
transformation might corrupt classes:
ClassReader cr = new ClassReader(buffer);
ClassWriter cw = new ClassWriter(cr, ClassWriter.C...```
Hello,
working with the ASM library I bumped into strange issue, the trivial
transformation might corrupt classes:
ClassReader cr = new ClassReader(buffer);
ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS);
cr.accept(cw, 0);
byte[] res = cw.toByteArray();
a stack size in particular, that causes VerifyError.
I minimized the test as possible. The steps below allows to reproduce the error.
----- Trans.java - code to perform class transformation ------
import java.io.FileInputStream;
import java.io.FileOutputStream;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
public class Trans {
public static void main(String[] args) {
String s = args[0];
try {
FileInputStream fis = new FileInputStream(s);
int size = fis.available();
byte[] buffer = new byte[size];
fis.read(buffer);
ClassReader cr = new ClassReader(buffer);
ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_MAXS);
cr.accept(cw, 0);
byte[] res = cw.toByteArray();
FileOutputStream fos = new FileOutputStream(s + ".i");
fos.write(res);
fos.flush();
fos.close();
System.out.println("Created: " + s + ".i");
} catch (Exception e) {
System.out.println(e.toString());
}
}
}
----- HelloWorld.java - subject of transformation ----
public class HelloWorld {
public static void main(String args[]) {
System.out.println("Hello world");
}
public void meth1() throws MyException {
}
public void meth2() {
try {
meth1();
} catch (MyException re) {
}
}
public void meth3() throws MyException {
try {
} finally {
}
}
static class MyException extends Exception {
}
}
------------------
Steps to reproduce:
# cp ../asm-3.3.1.jar .
# javac -cp asm-3.3.1.jar Trans.java
# javac HelloWorld.java
# java -cp .:asm-3.3.1.jar Trans HelloWorld.class
Created: HelloWorld.class.i
# java -cp . HelloWorld
Hello world
# mv HelloWorld.class HelloWorld.class.o
# cp HelloWorld.class.i HelloWorld.class
# java -cp . HelloWorld
Exception in threadjava "main" java.lang.VerifyError: (class: HelloWorld,
method: meth3 signature: ()V) Stack size too large
Could not find the main class: HelloWorld. Program will exit.
# java -version
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) Server VM (build 19.1-b02, mixed mode)
Note, the problem is reprosible as of jdk6u4.
I disassembled classes (with own tools) and there is only difference in the
stack size for 'meth3()'
public Method meth3:"()V"
throws HelloWorld$MyException
stack 1 locals 2
{...}
-->
public Method meth3:"()V"
throws HelloWorld$MyException
stack 0 locals 2
{...}
Should you have any question: feel free to ask me at: dmitry.fazunenko@oracle.com
```