Commit 6fe48a7a authored by Eric Bruneton's avatar Eric Bruneton

Fix the copy pool bug with version changes, make the previously added tests pass.

parent 498ac5c0
Pipeline #1458 passed with stage
in 6 minutes and 17 seconds
......@@ -976,6 +976,8 @@ public class ClassReader {
int exceptionsOffset = 0;
// - The strings corresponding to the Exceptions attribute, or null.
String[] exceptions = null;
// - Whether the method has a Synthetic attribute.
boolean synthetic = false;
// - The constant pool index contained in the Signature attribute, or 0.
int signatureIndex = 0;
// - The offset of the RuntimeVisibleAnnotations attribute, or 0.
......@@ -1030,6 +1032,7 @@ public class ClassReader {
} else if (Constants.ANNOTATION_DEFAULT.equals(attributeName)) {
annotationDefaultOffset = currentOffset;
} else if (Constants.SYNTHETIC.equals(attributeName)) {
synthetic = true;
context.currentMethodAccessFlags |= Opcodes.ACC_SYNTHETIC;
} else if (Constants.RUNTIME_INVISIBLE_ANNOTATIONS.equals(attributeName)) {
runtimeInvisibleAnnotationsOffset = currentOffset;
......@@ -1079,7 +1082,8 @@ public class ClassReader {
this,
methodInfoOffset,
currentOffset - methodInfoOffset,
context.currentMethodAccessFlags,
synthetic,
(context.currentMethodAccessFlags & Opcodes.ACC_DEPRECATED) != 0,
signatureIndex,
exceptionsOffset)) {
return currentOffset;
......
......@@ -1953,8 +1953,10 @@ final class MethodWriter extends MethodVisitor {
* the attributes of this method might be copied.
* @param methodInfoLength the length in 'source.b' of the method_info JVMS structure from which
* the attributes of this method might be copied.
* @param access the access flags (including the ASM specific ones) of the method_info JVMS
* structure from which the attributes of this method might be copied.
* @param hasSyntheticAttribute whether the method_info JVMS structure from which the attributes
* of this method might be copied contains a Synthetic attribute.
* @param hasDeprecatedAttribute whether the method_info JVMS structure from which the attributes
* of this method might be copied contains a Deprecated attribute.
* @param signatureIndex the constant pool index contained in the Signature attribute of the
* method_info JVMS structure from which the attributes of this method might be copied, or 0.
* @param exceptionsOffset the offset in 'source.b' of the Exceptions attribute of the method_info
......@@ -1967,17 +1969,18 @@ final class MethodWriter extends MethodVisitor {
final ClassReader source,
final int methodInfoOffset,
final int methodInfoLength,
final int access,
final boolean hasSyntheticAttribute,
final boolean hasDeprecatedAttribute,
final int signatureIndex,
final int exceptionsOffset) {
if (source != symbolTable.getSource()
|| signatureIndex != this.signatureIndex
|| (access & Opcodes.ACC_DEPRECATED) != (accessFlags & Opcodes.ACC_DEPRECATED)) {
|| hasDeprecatedAttribute != ((accessFlags & Opcodes.ACC_DEPRECATED) != 0)) {
return false;
}
boolean useSyntheticAttribute = symbolTable.getMajorVersion() < Opcodes.V1_5;
if (useSyntheticAttribute
&& (access & Opcodes.ACC_SYNTHETIC) != (accessFlags & Opcodes.ACC_SYNTHETIC)) {
boolean needSyntheticAttribute =
symbolTable.getMajorVersion() < Opcodes.V1_5 && (accessFlags & Opcodes.ACC_SYNTHETIC) != 0;
if (hasSyntheticAttribute != needSyntheticAttribute) {
return false;
}
if (exceptionsOffset == 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment