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

Merge branch '317885-skip-method-parameters-if-skip-debug' into 'master'

Skip the MethodParameters attribute if SKIP_DEBUG is used.

Closes #317885

See merge request asm/asm!278
parents 279a5058 6623d074
Pipeline #6785 passed with stage
in 9 minutes and 40 seconds
......@@ -50,10 +50,11 @@ public class ClassReader {
public static final int SKIP_CODE = 1;
/**
* A flag to skip the SourceFile, SourceDebugExtension, LocalVariableTable, LocalVariableTypeTable
* and LineNumberTable attributes. If this flag is set these attributes are neither parsed nor
* visited (i.e. {@link ClassVisitor#visitSource}, {@link MethodVisitor#visitLocalVariable} and
* {@link MethodVisitor#visitLineNumber} are not called).
* A flag to skip the SourceFile, SourceDebugExtension, LocalVariableTable,
* LocalVariableTypeTable, LineNumberTable and MethodParameters attributes. If this flag is set
* these attributes are neither parsed nor visited (i.e. {@link ClassVisitor#visitSource}, {@link
* MethodVisitor#visitLocalVariable}, {@link MethodVisitor#visitLineNumber} and {@link
* MethodVisitor#visitParameter} are not called).
*/
public static final int SKIP_DEBUG = 2;
......@@ -1164,7 +1165,7 @@ public class ClassReader {
}
// Visit the MethodParameters attribute.
if (methodParametersOffset != 0) {
if (methodParametersOffset != 0 && (context.parsingOptions & SKIP_DEBUG) == 0) {
int parametersCount = readByte(methodParametersOffset);
int currentParameterOffset = methodParametersOffset + 1;
while (parametersCount-- > 0) {
......
......@@ -288,7 +288,15 @@ public class ClassReaderTest extends AsmTest implements Opcodes {
Executable accept = () -> classReader.accept(classVisitor, ClassReader.SKIP_DEBUG);
if (classParameter.isMoreRecentThan(apiParameter)) {
// The following jdk8 classes contain MethodParameters attributes which require ASM5. Here we
// skip these attributes with SKIP_DEBUG, and these classes contain no other features requiring
// ASM5 or more, so they can be read with ASM4.
if (classParameter.isMoreRecentThan(apiParameter)
&& classParameter != PrecompiledClass.JDK8_ALL_FRAMES
&& classParameter != PrecompiledClass.JDK8_ALL_STRUCTURES
&& classParameter != PrecompiledClass.JDK8_ANONYMOUS_INNER_CLASS
&& classParameter != PrecompiledClass.JDK8_INNER_CLASS
&& classParameter != PrecompiledClass.JDK8_LARGE_METHOD) {
Exception exception = assertThrows(UnsupportedOperationException.class, accept);
assertTrue(exception.getMessage().matches(UNSUPPORTED_OPERATION_MESSAGE_PATTERN));
} else {
......
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