asm issueshttps://gitlab.ow2.org/asm/asm/-/issues2017-12-26T09:58:58Zhttps://gitlab.ow2.org/asm/asm/-/issues/317567SerialVersionUIDAdder issues2017-12-26T09:58:58ZztandresSerialVersionUIDAdder issues```
We are using a custom version of SerialVersionUIDAdder. The issues with the
original are the following:
1) serialVersionUID should be 0L for enums:
http://docs.oracle.com/javase/6/docs/platform/serialization/spec/serial-arch.html#646...```
We are using a custom version of SerialVersionUIDAdder. The issues with the
original are the following:
1) serialVersionUID should be 0L for enums:
http://docs.oracle.com/javase/6/docs/platform/serialization/spec/serial-arch.html#6469
> Similarly, any serialPersistentFields or serialVersionUID field declarations
are also ignored--all enum types have a fixed serialVersionUID of 0L
But with ASM it will be a number.
Javas util "serialver" gives a 0L for serialVersionUID.
2) serialVersionUID should be computed to interfaces because interfaces can
have a serialVersionUID field.
"serialver" gives a default serialVersionUID.
2*) When computing serialVersionUID for an interface with 0 methods. Then the
class should be counted as non-abstract, this can be checked by comparing
results with "serialver".
In code:
visit(...):
computeSVUID = (access & Opcodes.ACC_INTERFACE) == 0;
->
computeSVUID = (access & Opcodes.ACC_ENUM) == 0;
computeSVUID():
before dos.writeInt
int access = this.access;
if ((access & Opcodes.ACC_INTERFACE) != 0)
access = (svuidMethods.size() > 0) ? (access | Opcodes.ACC_ABSTRACT) : (access
& ~Opcodes.ACC_ABSTRACT);
```https://gitlab.ow2.org/asm/asm/-/issues/317561ArrayIndexOutOfBoundsException in ClassReader2017-12-26T09:59:19ZadligoArrayIndexOutOfBoundsException in ClassReader```
Hi,
I was ran into a ArrayIndexOutOfBoundException when trying to read the attached class;
Here is the stacktrace;
java.lang.ArrayIndexOutOfBoundsException: 6
at org.objectweb.asm.ClassReader.readShort(ClassReader.java:2326)
a...```
Hi,
I was ran into a ArrayIndexOutOfBoundException when trying to read the attached class;
Here is the stacktrace;
java.lang.ArrayIndexOutOfBoundsException: 6
at org.objectweb.asm.ClassReader.readShort(ClassReader.java:2326)
at org.objectweb.asm.ClassReader.<init>(ClassReader.java:169)
at org.objectweb.asm.ClassReader.<init>(ClassReader.java:153)
at org.objectweb.asm.ClassReader.<init>(ClassReader.java:424)
TIA,
Scott
```https://gitlab.ow2.org/asm/asm/-/issues/317568NPE in MethodWriter.visitMaxs2017-12-26T09:58:44ZjfdeniseNPE in MethodWriter.visitMaxs```
I have isolated and attached a simplified test case that reveals the NPE. I am running ASM 5.0.3
I am removing the instructions of an exception handler as well as the associated TryCatchBlockNode
instance.
This does work except w...```
I have isolated and attached a simplified test case that reveals the NPE. I am running ASM 5.0.3
I am removing the instructions of an exception handler as well as the associated TryCatchBlockNode
instance.
This does work except when a method is of the form of the NPETestCase.fails method. In this case I am
running into the following NPE:
Exception in thread "main" java.lang.NullPointerException
at jdk.internal.org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1570)
at jdk.internal.org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:864)
at jdk.internal.org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:756)
at jdk.internal.org.objectweb.asm.tree.ClassNode.accept(ClassNode.java:441)
at asm_npe1.TestNPE.main(TestNPE.java:50)
To run the test case. Open the project in netbeans and run it. If no netbeans, build the classes, run the
java class asm_npe1.TestNPE passing it the path to where the class asm_npe1.NPETestCase.class has been
generated.
```https://gitlab.ow2.org/asm/asm/-/issues/317559"Incompatible InnerClasses attribute" error in IBM J9 VM2017-12-26T09:59:46Zztandres"Incompatible InnerClasses attribute" error in IBM J9 VM```
ASM generates unexpected bytecode get's the following exception in some certain
cases on IBM JVM:
Caused by: java.lang.IncompatibleClassChangeError: incompatible InnerClasses
attribute between "org.zeroturnaround.Erroneous$MyInner" a...```
ASM generates unexpected bytecode get's the following exception in some certain
cases on IBM JVM:
Caused by: java.lang.IncompatibleClassChangeError: incompatible InnerClasses
attribute between "org.zeroturnaround.Erroneous$MyInner" and
"org.zeroturnaround.Erroneous"
I have seen this error before and also found a jenkins bug caused by it:
https://issues.jenkins-ci.org/browse/JENKINS-22525
The cause seems to be that in some cases the compiled byte code has 2 class
references to the same class. In the original bytecode the first reference is
used, but after ASM parses the class both references are used and this causes
some trouble for IBM JVM.
Based on that I managed to make a reproduction application. When you look at
the bytecode before and after the transformation you can see the difference.
One fix I found would be to change
ClassWriter
private Item get(final Item key) {
Item i = items[key.hashCode % items.length];
Item best = null;
while (i != null) {
if (i.type == key.type && key.isEqualTo(i)) {
if (best == null) {
best = i;
} else if (best.index > i.index) {
best = i;
}
}
i = i.next;
}
return best;
}
```https://gitlab.ow2.org/asm/asm/-/issues/317604Bug in AdviceAdapter.visitFieldInsn()2017-12-26T09:50:57ZtraskBug in AdviceAdapter.visitFieldInsn()```
Hi, I just wanted to report this issue I ran into:
Existing code:
case PUTFIELD:
popValue();
if (longOrDouble) {
popValue();
popValue();
}
break;
Should be:
case PUT...```
Hi, I just wanted to report this issue I ran into:
Existing code:
case PUTFIELD:
popValue();
if (longOrDouble) {
popValue();
popValue();
}
break;
Should be:
case PUTFIELD:
popValue();
popValue();
if (longOrDouble) {
popValue();
}
break;
Thanks,
Trask
```https://gitlab.ow2.org/asm/asm/-/issues/317586VerifyError caused by LocalVariablesSorter2018-02-24T09:42:16ZjemrVerifyError caused by LocalVariablesSorter```
The LocalVariablesSorter will sometimes produce incorrect frames causing verification error.
The following method, when compiled with the eclipse compiler, will cause VerifyError, if run through the
LocalVariablesSorter:
void sa...```
The LocalVariablesSorter will sometimes produce incorrect frames causing verification error.
The following method, when compiled with the eclipse compiler, will cause VerifyError, if run through the
LocalVariablesSorter:
void sample() throws Exception {
try (BufferedReader reader = new BufferedReader(new StringReader("1\n2\n3\n4\n"))) {
String line;
while ((line = reader.readLine()) != null) {
int columnidx = 0;
Integer.parseInt(line);
}
}
}
the above with "Bad local variable type", if commenting out the parseInt line, then with: "Inconsistent stackmap frames"
It seems the "changed" flag in the LocalVariablesSorter isn't set, even though something is remapped?
See attached zip for sample (includes .class files as compiled with eclipse compiler).
```https://gitlab.ow2.org/asm/asm/-/issues/317555NPE in MethodWriter.resizeInstructions()2017-12-26T10:00:47ZmarchofNPE in MethodWriter.resizeInstructions()```
ASM Version: 5.0.1
While working on a reproducer for issue 317551 I came across the following NPE
while creating a large method:
Exception in thread "main" java.lang.NullPointerException
at org.objectweb.asm.MethodWriter.resizeIns...```
ASM Version: 5.0.1
While working on a reproducer for issue 317551 I came across the following NPE
while creating a large method:
Exception in thread "main" java.lang.NullPointerException
at org.objectweb.asm.MethodWriter.resizeInstructions(MethodWriter.java:2709)
at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1407)
at org.objectweb.asm.ClassReader.readCode(ClassReader.java:1554)
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.objectweb.asm.ClassWriter.toByteArray(ClassWriter.java:995)
at LargeMethodNPE.main(LargeMethodNPE.java:18)
Please find the reproducer attached.
Maybe I made a mistake using the visitor APIs, but a smaller version of the
same class (less NOP instructions) can be built and also loads into the JVM.
```https://gitlab.ow2.org/asm/asm/-/issues/317558Stack frame tag - wrong specification2017-12-26T10:00:33ZhenStack frame tag - wrong specification```
In class Reader under method readFrame
private int readFrame(int stackMap, boolean zip, boolean unzip,
Context frame)
{
..
..
..
if (zip)
{
tag = b[stackMap++] & 0xFF;
} else {
tag = MethodWri...```
In class Reader under method readFrame
private int readFrame(int stackMap, boolean zip, boolean unzip,
Context frame)
{
..
..
..
if (zip)
{
tag = b[stackMap++] & 0xFF;
} else {
tag = MethodWriter.FULL_FRAME;
frame.offset = -1;
}
..
..
}
Why are you assuming that if zip var is true then the frame tag is FULL_FRAME
?
The zip flag is being determined according to the following code located under
the method called readCode:
private void readCode(final MethodVisitor mv, final Context context, int u)
{
..
..
else if (FRAMES && "StackMap".equals(attrName)) {
if ((context.flags & SKIP_FRAMES) == 0) {
zip = false;
stackMap = u + 10;
stackMapSize = readInt(u + 4);
frameCount = readUnsignedShort(u + 8);
}
..
..
}
Running a degenerate method visitor on the attached class causing to the
following Exception:
java.lang.ArrayIndexOutOfBoundsException: 3
at org.objectweb.asm.ClassReader.readFrameType(ClassReader.java:2142)
at org.objectweb.asm.ClassReader.readFrame(Unknown Source)
at org.objectweb.asm.ClassReader.readCode(Unknown Source)
at org.objectweb.asm.ClassReader.readMethod(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
There is no full frame in the method StackMap (Output using javap):
StackMap: length = 0x5
00 03 18 07 07
You can see that the attribute_length is 3 and all the entries are less then
63, which means the frames should be tagged as same_frame
Attached is the relevant class
Thanks,
Hen
```https://gitlab.ow2.org/asm/asm/-/issues/317601Packaging problems in asm2017-12-26T09:52:12ZbriantoppingPackaging problems in asm```
While deploying asm, I found the library doing a dynamic load of
org.objectweb.asm.commons.AdviceAdapter. Interestingly, that code is in the source jar but not in the
binary. Further digging shows the class in asm-commons.
There ...```
While deploying asm, I found the library doing a dynamic load of
org.objectweb.asm.commons.AdviceAdapter. Interestingly, that code is in the source jar but not in the
binary. Further digging shows the class in asm-commons.
There are probably two problems here:
1) https://repo1.maven.org/maven2/org/ow2/asm/asm/5.0.4/asm-5.0.4.pom should have an optional scope
dependency from asm to asm-commons
2) The source for asm and it's source jar needs to be checked for 1:1 correlations between the two artifacts.
```https://gitlab.ow2.org/asm/asm/-/issues/317602Asmifier does not recognize null value for TypePath2017-12-26T09:51:51ZraphwAsmifier does not recognize null value for TypePath```
The Asmifier does not consider the possibility that a TypePath for a type
annotation can be null an renders incorrect example code.
A patch is attached.
``````
The Asmifier does not consider the possibility that a TypePath for a type
annotation can be null an renders incorrect example code.
A patch is attached.
```https://gitlab.ow2.org/asm/asm/-/issues/317553StaticInitMerger breaks interfaces2017-12-26T10:01:31ZhoescheleStaticInitMerger breaks interfaces```
With a chain of ClassReader->StaticInitMerger->ClassWriter interfaces like this
http://grepcode.com/file_/repo1.maven.org/maven2/net.java.dev.glazedlists/glazedlists_java15/1.8.0/ca/odell/glazedlists/util/concurrent/LockFactory.java/...```
With a chain of ClassReader->StaticInitMerger->ClassWriter interfaces like this
http://grepcode.com/file_/repo1.maven.org/maven2/net.java.dev.glazedlists/glazedlists_java15/1.8.0/ca/odell/glazedlists/util/concurrent/LockFactory.java/?v=source
are corrupted and the Java VM will complain about illegal modifiers for methods.
The scenario is the following:
Some interfaces have a static fields which are assigned values that require
method calls. In bytecode this non-trivial assignment is compiled to a <clinit>
(however explicit static initializers in interfaces are not allowed by the Java
compiler).
StaticInitMerger simply renames all static initializers it finds and calls them
all in the single static initializer it creates.
In the case of the mentioned interface this results in one additional
non-abstract method in the interface which is not allowed by the Java VM. To
fix this special case we might want to combine/inline all initializers into a
single one in order to fix this problem.
I know that fields in interfaces are considered as bad practice by many
developers but this unfortunately happens in quite a lot of libraries which I
cannot simply ignore/replace.
```https://gitlab.ow2.org/asm/asm/-/issues/317554Missing Java 8 support in ClassReader2017-12-26T10:01:12ZraffigMissing Java 8 support in ClassReader```
Regards version 5.0.3
In this method:
org.objectweb.asm.ClassReader.ClassReader(byte[], int, int)
There is a fragment:
if (readShort(off + 6) > Opcodes.V1_7) {
throw new IllegalArgumentException();
}
(...```
Regards version 5.0.3
In this method:
org.objectweb.asm.ClassReader.ClassReader(byte[], int, int)
There is a fragment:
if (readShort(off + 6) > Opcodes.V1_7) {
throw new IllegalArgumentException();
}
(lines 169-171)
It seems that support for Java 8 is missing here.
```https://gitlab.ow2.org/asm/asm/-/issues/317600Bad behavior of Type utility class with anonymously loaded classes2017-12-26T09:52:33ZraphwBad behavior of Type utility class with anonymously loaded classes```
Anonymous loaded classes (via sun.misc.Unsafe) have a different naming schema
where a name is called:
foo.Bar/12345
The utilities of the Type class do not properly account to this possibile
naming schema and do not return the right...```
Anonymous loaded classes (via sun.misc.Unsafe) have a different naming schema
where a name is called:
foo.Bar/12345
The utilities of the Type class do not properly account to this possibile
naming schema and do not return the right names for such classes.
```https://gitlab.ow2.org/asm/asm/-/issues/317626AnnotationNode incorrectly process array values in 'visit(final String name, ...2018-01-21T08:00:13ZkammererAnnotationNode incorrectly process array values in 'visit(final String name, final Object value)' method```
According to javadoc 'AnnotationNode.values' field contains only simple values
or lists of them, but not arrays (except enum case).
Java doc of 'AnnotationVisitor.visit(final String name, final Object value)'
says that it accepts arr...```
According to javadoc 'AnnotationNode.values' field contains only simple values
or lists of them, but not arrays (except enum case).
Java doc of 'AnnotationVisitor.visit(final String name, final Object value)'
says that it accepts arrays and in such case it's a shortcut for 'visitArray'
and array elements iteration.
AnnotationNode do nothing to process such shortcuts and as result writes arrays
of primitives to 'values' field.
Simple case to reproduce: pass AnnotationNode to ClassReader
```https://gitlab.ow2.org/asm/asm/-/issues/317587ArrayIndexOutOfBoundsException while reading a class file2017-12-26T09:53:34ZmetlosArrayIndexOutOfBoundsException while reading a class file```
I have a simple class reader that I am using to read the structure of a class.
I get an ArrayIndexOutOfBoundsException when trying to use this to read class
com.ibm.icu.impl.data.LocaleElements_zh__PINYIN from icu4j version 2.6.1
(ht...```
I have a simple class reader that I am using to read the structure of a class.
I get an ArrayIndexOutOfBoundsException when trying to use this to read class
com.ibm.icu.impl.data.LocaleElements_zh__PINYIN from icu4j version 2.6.1
(http://search.maven.org/#artifactdetails|com.ibm.icu|icu4j|2.6.1|jar).
In the attached Maven project the "test.class" is a class file of the above
mentioned class.
Repro steps:
unzip the attached reproducer.zip and run:
mvn package exec:java -Dexec.mainClass=Main
```https://gitlab.ow2.org/asm/asm/-/issues/317548Mistakes in API documentation of MethodVisitor and SignatureVisitor2017-12-26T10:02:12ZtrohovskyMistakes in API documentation of MethodVisitor and SignatureVisitor```
MethodVisitor
- visitParameterAnnotation is missing in the desciption of method calling order
- visitTryCatchAnnotation vs. current visitTryCatchBlockAnnotation
SignatureVisitor
- visitSuperclass vs. current visitSuperClass
``````
MethodVisitor
- visitParameterAnnotation is missing in the desciption of method calling order
- visitTryCatchAnnotation vs. current visitTryCatchBlockAnnotation
SignatureVisitor
- visitSuperclass vs. current visitSuperClass
```https://gitlab.ow2.org/asm/asm/-/issues/317545Asm eat linenumbers if there are several of them on one label2017-12-26T10:02:52ZkammererAsm eat linenumbers if there are several of them on one label```
Java bytecode allows to write several linenumbers on one label (see example
below) but asm keeps only one line. So it's impossible read and verify all
bytecode information using ClassReader.MethodVisitor
LineNumberTable:
...```
Java bytecode allows to write several linenumbers on one label (see example
below) but asm keeps only one line. So it's impossible read and verify all
bytecode information using ClassReader.MethodVisitor
LineNumberTable:
line 20: 0
line 21: 5
line 23: 27
line 20: 46
line 26: 46
line 27: 51
line 29: 72
line 26: 90
ClassReader.MethodVisitor.visitLineNumber say that label 46 corresponds only to
line 26 and skips entry for line 20: 46
```https://gitlab.ow2.org/asm/asm/-/issues/317547incorrect owner argument of ASM MethodWriter#visitFieldInsn when dealing with...2017-12-26T10:02:38Zyilongliincorrect owner argument of ASM MethodWriter#visitFieldInsn when dealing with static field```
Consider the following example:
public class Test extends Test2 {
public static void main(String[] args) {
staticVariable = true;
Test2.staticVariable = true;
}
}
class Test2 {
static boolean staticVaria...```
Consider the following example:
public class Test extends Test2 {
public static void main(String[] args) {
staticVariable = true;
Test2.staticVariable = true;
}
}
class Test2 {
static boolean staticVariable;
}
The owner argument in MethodWriter#visitFieldInsn(int opcode, String owner,
String name, String desc) for the first access of staticVariable is "Test" while
the second one is "Test2".
This doesn't look right to me. I am using ASM 5.02.
```https://gitlab.ow2.org/asm/asm/-/issues/317541Java 8 + hibernate validator = IllegalArgumentException2017-12-26T10:03:19ZmikecurwenJava 8 + hibernate validator = IllegalArgumentException```
I've include a small project which replicates the issue.
Using java 1.8.0_20 , asm 5.0.3 and hibernate validator 5.1.2.Final (see
pom.xml for other info).
The stacktrace is:
java.lang.IllegalArgumentException
at net.sf.cglib.a...```
I've include a small project which replicates the issue.
Using java 1.8.0_20 , asm 5.0.3 and hibernate validator 5.1.2.Final (see
pom.xml for other info).
The stacktrace is:
java.lang.IllegalArgumentException
at net.sf.cglib.asm.ClassReader.<init>(Unknown Source)
at net.sf.cglib.asm.ClassReader.<init>(Unknown Source)
at net.sf.cglib.asm.ClassReader.<init>(Unknown Source)
at
net.sf.cglib.proxy.BridgeMethodResolver.resolveAll(BridgeMethodResolver.java:61
)
at net.sf.cglib.proxy.Enhancer.emitMethods(Enhancer.java:911)
at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:498)
at
net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.ja
va:25)
at
net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216
)
at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
at net.sf.cglib.proxy.Enhancer.createClass(Enhancer.java:317)
at
org.easymock.internal.ClassProxyFactory.createProxy(ClassProxyFactory.java:175)
at org.easymock.internal.MocksControl.createMock(MocksControl.java:114)
at org.easymock.internal.MocksControl.createMock(MocksControl.java:88)
at org.easymock.internal.MockBuilder.createMock(MockBuilder.java:206)
at org.easymock.internal.MockBuilder.createMock(MockBuilder.java:219)
at org.easymock.internal.MockBuilder.createMock(MockBuilder.java:188)
at
com.company.app.module.constraint.validator.FooValidatorNoJava8Test.createParti
alMock(FooValidatorNoJava8Test.java:38)
at
com.company.app.module.constraint.validator.FooValidatorNoJava8Test.testValid(F
ooValidatorNoJava8Test.java:25
```https://gitlab.ow2.org/asm/asm/-/issues/317560Method Remapping: InvokeDynamicInsn#name2018-04-15T13:14:15ZcalebMethod Remapping: InvokeDynamicInsn#name```
I'm currently writing an obfuscator supporting the java 8 language level (lambdas, default interfaces etc).
At the moment I'm focusing on method name obfuscation.
Here is the transformer along with the rest of the project
https://gi...```
I'm currently writing an obfuscator supporting the java 8 language level (lambdas, default interfaces etc).
At the moment I'm focusing on method name obfuscation.
Here is the transformer along with the rest of the project
https://github.com/RevTek/Revtek-ASM-Obfuscator/blob/master/com/revtek/rasmo/obfuscate/ScrambleMethods.java
Its entirely possible I'm completely mistaken and just haven't done everything properly.
Here is an example of where the instructions weren't transformed.
Source: https://gist.github.com/RevTek/8293ebbef263eb606d5f
Obfuscated Source: https://gist.github.com/RevTek/8624a686bab369bc56a3
Obfuscated Bytecode: https://gist.github.com/RevTek/74d1ea05739d4c879c7b#file-gistfile1-txt-L54
Obfuscated DangerousTask class
https://gist.github.com/RevTek/eb89dd460c60793bdf92
As you can see, other calls to the DangerousTask class are correctly transformed, except the InvokeDynamicInsn#name, it is
still referred to as "execute", it should be "ce"
I apologize for the sloppy layout of this post, its difficult to make it neat when there are a lot of resources needed to
show the problem.
```Remi ForaxRemi Forax