Top Description Inners Constructors Methods
org.codehaus.groovy.ast.decompiled

public abstract Class AsmDecompiler

extends Object
Class Inheritance
Imports
groovy.lang.GroovyRuntimeException, org.codehaus.groovy.control.CompilerConfiguration, org.codehaus.groovy.util.URLStreams, org.objectweb.asm.AnnotationVisitor, .ClassReader, .ClassVisitor, .FieldVisitor, .MethodVisitor, .Type, java.io.BufferedInputStream, .IOException, .InputStream, java.lang.ref.SoftReference, java.net.URI, .URISyntaxException, .URL, java.util.ArrayList, .HashMap, .List, .Map, java.util.concurrent.ConcurrentHashMap

A utility class responsible for decompiling JVM class files and producing ClassStub objects reflecting their structure.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private abstract static class
private static class
private static class

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
pack-priv static String
public static ClassStub

Returns:

the class stub
parseClass
(URL
an URL from a class loader, most likely a file system file or a JAR entry.
url
)

Loads the URL contents and parses them with ASM, producing a ClassStub object representing the structure of the corresponding class file.

private static AsmDecompiler.AnnotationReader
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

AsmDecompilerback to summary
public AsmDecompiler()

Method Detail

fromInternalNameback to summary
pack-priv static String fromInternalName(String name)
parseClassback to summary
public static ClassStub parseClass(URL url) throws IOException

Loads the URL contents and parses them with ASM, producing a ClassStub object representing the structure of the corresponding class file. Stubs are cached and reused if queried several times with equal URLs.

Parameters
url:URL

an URL from a class loader, most likely a file system file or a JAR entry.

Returns:ClassStub

the class stub

Exceptions
IOException:
if reading from this URL is impossible
readAnnotationMembersback to summary
private static AsmDecompiler.AnnotationReader readAnnotationMembers(final AnnotationStub stub)
org.codehaus.groovy.ast.decompiled back to summary

private abstract Class AsmDecompiler.AnnotationReader

extends AnnotationVisitor
Class Inheritance

Field Summary

Inherited from org.objectweb.asm.AnnotationVisitor:
apiav

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
visit(String
the value name.
name
,
Object
the actual value, whose type must be Byte, Boolean, Character, Short, Integer , Long, Float, Double, String or Type of Type#OBJECT or Type#ARRAY sort. This value can also be an array of byte, boolean, short, char, int, long, float or double values (this is equivalent to using visitArray and visiting each array element in turn, but is more convenient).
value
)

Overrides org.objectweb.asm.AnnotationVisitor.visit.

Visits a primitive value of the annotation.
public AnnotationVisitor
visitAnnotation(String
the value name.
name
,
String
the class descriptor of the nested annotation class.
desc
)

Overrides org.objectweb.asm.AnnotationVisitor.visitAnnotation.

Visits a nested annotation value of the annotation.
public AnnotationVisitor
visitArray(String
the value name.
name
)

Overrides org.objectweb.asm.AnnotationVisitor.visitArray.

Visits an array value of the annotation.
pack-priv abstract void
public void
visitEnum(String
the value name.
name
,
String
the class descriptor of the enumeration class.
desc
,
String
the actual enumeration value.
value
)

Overrides org.objectweb.asm.AnnotationVisitor.visitEnum.

Visits an enumeration value of the annotation.
Inherited from org.objectweb.asm.AnnotationVisitor:
getDelegatevisitEnd

Constructor Detail

AnnotationReaderback to summary
public AnnotationReader()

Method Detail

visitback to summary
public void visit(String name, Object value)

Overrides org.objectweb.asm.AnnotationVisitor.visit.

Doc from org.objectweb.asm.AnnotationVisitor.visit.

Visits a primitive value of the annotation.

Parameters
name:String

the value name.

value:Object

the actual value, whose type must be Byte, Boolean, Character, Short, Integer , Long, Float, Double, String or Type of Type#OBJECT or Type#ARRAY sort. This value can also be an array of byte, boolean, short, char, int, long, float or double values (this is equivalent to using visitArray and visiting each array element in turn, but is more convenient).

Annotations
@Override
visitAnnotationback to summary
public AnnotationVisitor visitAnnotation(String name, String desc)

Overrides org.objectweb.asm.AnnotationVisitor.visitAnnotation.

Doc from org.objectweb.asm.AnnotationVisitor.visitAnnotation.

Visits a nested annotation value of the annotation.

Parameters
name:String

the value name.

desc:String

the class descriptor of the nested annotation class.

Returns:AnnotationVisitor

a visitor to visit the actual nested annotation value, or null if this visitor is not interested in visiting this nested annotation. The nested annotation value must be fully visited before calling other methods on this annotation visitor.

Annotations
@Override
visitArrayback to summary
public AnnotationVisitor visitArray(String name)

Overrides org.objectweb.asm.AnnotationVisitor.visitArray.

Doc from org.objectweb.asm.AnnotationVisitor.visitArray.

Visits an array value of the annotation. Note that arrays of primitive values (such as byte, boolean, short, char, int, long, float or double) can be passed as value to visit. This is what ClassReader does for non empty arrays of primitive values.

Parameters
name:String

the value name.

Returns:AnnotationVisitor

a visitor to visit the actual array value elements, or null if this visitor is not interested in visiting these values. The 'name' parameters passed to the methods of this visitor are ignored. All the array values must be visited before calling other methods on this annotation visitor.

Annotations
@Override
visitAttributeback to summary
pack-priv abstract void visitAttribute(String name, Object value)
visitEnumback to summary
public void visitEnum(String name, String desc, String value)

Overrides org.objectweb.asm.AnnotationVisitor.visitEnum.

Doc from org.objectweb.asm.AnnotationVisitor.visitEnum.

Visits an enumeration value of the annotation.

Parameters
name:String

the value name.

desc:String

the class descriptor of the enumeration class.

value:String

the actual enumeration value.

Annotations
@Override
org.codehaus.groovy.ast.decompiled back to summary

private Class AsmDecompiler.DecompilingVisitor

extends ClassVisitor
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final String[]
private ClassStub
Inherited from org.objectweb.asm.ClassVisitor:
apicv

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
visit(int
the class version. The minor version is stored in the 16 most significant bits, and the major version in the 16 least significant bits.
version
,
int
the class's access flags (see Opcodes). This parameter also indicates if the class is deprecated Opcodes#ACC_DEPRECATED or a record Opcodes#ACC_RECORD.
access
,
String
the internal name of the class (see Type#getInternalName()).
name
,
String
the signature of this class. May be null if the class is not a generic one, and does not extend or implement generic classes or interfaces.
signature
,
String
the internal of name of the super class (see Type#getInternalName()). For interfaces, the super class is Object. May be null, but only for the Object class.
superName
,
String[]
the internal names of the class's interfaces (see Type#getInternalName()). May be null.
interfaceNames
)

Overrides org.objectweb.asm.ClassVisitor.visit.

Visits the header of the class.
public AnnotationVisitor
visitAnnotation(String
the class descriptor of the annotation class.
desc
,
boolean
true if the annotation is visible at runtime.
visible
)

Overrides org.objectweb.asm.ClassVisitor.visitAnnotation.

Visits an annotation of the class.
public FieldVisitor
visitField(int
the field's access flags (see Opcodes). This parameter also indicates if the field is synthetic and/or deprecated.
access
,
String
the field's name.
name
,
String
the field's descriptor (see Type).
desc
,
String
the field's signature. May be null if the field's type does not use generic types.
signature
,
Object
the field's initial value. This parameter, which may be null if the field does not have an initial value, must be an Integer, a Float, a Long, a Double or a String (for int, float, long or String fields respectively). This parameter is only used for static fields. Its value is ignored for non static fields, which must be initialized through bytecode instructions in constructors or methods.
value
)

Overrides org.objectweb.asm.ClassVisitor.visitField.

Visits a field of the class.
public void
visitInnerClass(String
the internal name of C (see Type#getInternalName()).
name
,
String
the internal name of the class or interface C is a member of (see Type#getInternalName()). Must be null if C is not the member of a class or interface (e.g. for local or anonymous classes).
outerName
,
String
the (simple) name of C. Must be null for anonymous inner classes.
innerName
,
int
the access flags of C originally declared in the source code from which this class was compiled.
access
)

Overrides org.objectweb.asm.ClassVisitor.visitInnerClass.

Visits information about an inner class.
public MethodVisitor
visitMethod(int
the method's access flags (see Opcodes). This parameter also indicates if the method is synthetic and/or deprecated.
access
,
String
the method's name.
name
,
String
the method's descriptor (see Type).
desc
,
String
the method's signature. May be null if the method parameters, return type and exceptions do not use generic types.
signature
,
String[]
the internal names of the method's exception classes (see Type#getInternalName()). May be null.
exceptions
)

Overrides org.objectweb.asm.ClassVisitor.visitMethod.

Visits a method of the class.
Inherited from org.objectweb.asm.ClassVisitor:
getDelegatevisitAttributevisitEndvisitModulevisitNestHostvisitNestMembervisitOuterClassvisitPermittedSubclassvisitRecordComponentvisitSourcevisitTypeAnnotation

Field Detail

EMPTY_STRING_ARRAYback to summary
private static final String[] EMPTY_STRING_ARRAY
resultback to summary
private ClassStub result

Constructor Detail

DecompilingVisitorback to summary
public DecompilingVisitor()

Method Detail

visitback to summary
public void visit(int version, int access, String name, String signature, String superName, String[] interfaceNames)

Overrides org.objectweb.asm.ClassVisitor.visit.

Doc from org.objectweb.asm.ClassVisitor.visit.

Visits the header of the class.

Parameters
version:int

the class version. The minor version is stored in the 16 most significant bits, and the major version in the 16 least significant bits.

access:int

the class's access flags (see Opcodes). This parameter also indicates if the class is deprecated Opcodes#ACC_DEPRECATED or a record Opcodes#ACC_RECORD.

name:String

the internal name of the class (see Type#getInternalName()).

signature:String

the signature of this class. May be null if the class is not a generic one, and does not extend or implement generic classes or interfaces.

superName:String

the internal of name of the super class (see Type#getInternalName()). For interfaces, the super class is Object. May be null, but only for the Object class.

interfaceNames:String[]

the internal names of the class's interfaces (see Type#getInternalName()). May be null.

Annotations
@Override
visitAnnotationback to summary
public AnnotationVisitor visitAnnotation(String desc, boolean visible)

Overrides org.objectweb.asm.ClassVisitor.visitAnnotation.

Doc from org.objectweb.asm.ClassVisitor.visitAnnotation.

Visits an annotation of the class.

Parameters
desc:String

the class descriptor of the annotation class.

visible:boolean

true if the annotation is visible at runtime.

Returns:AnnotationVisitor

a visitor to visit the annotation values, or null if this visitor is not interested in visiting this annotation.

Annotations
@Override
visitFieldback to summary
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value)

Overrides org.objectweb.asm.ClassVisitor.visitField.

Doc from org.objectweb.asm.ClassVisitor.visitField.

Visits a field of the class.

Parameters
access:int

the field's access flags (see Opcodes). This parameter also indicates if the field is synthetic and/or deprecated.

name:String

the field's name.

desc:String

the field's descriptor (see Type).

signature:String

the field's signature. May be null if the field's type does not use generic types.

value:Object

the field's initial value. This parameter, which may be null if the field does not have an initial value, must be an Integer, a Float, a Long, a Double or a String (for int, float, long or String fields respectively). This parameter is only used for static fields. Its value is ignored for non static fields, which must be initialized through bytecode instructions in constructors or methods.

Returns:FieldVisitor

a visitor to visit field annotations and attributes, or null if this class visitor is not interested in visiting these annotations and attributes.

Annotations
@Override
visitInnerClassback to summary
public void visitInnerClass(String name, String outerName, String innerName, int access)

Overrides org.objectweb.asm.ClassVisitor.visitInnerClass.

Doc from org.objectweb.asm.ClassVisitor.visitInnerClass.

Visits information about an inner class. This inner class is not necessarily a member of the class being visited. More precisely, every class or interface C which is referenced by this class and which is not a package member must be visited with this method. This class must reference its nested class or interface members, and its enclosing class, if any. See the JVMS 4.7.6 section for more details.

Parameters
name:String

the internal name of C (see Type#getInternalName()).

outerName:String

the internal name of the class or interface C is a member of (see Type#getInternalName()). Must be null if C is not the member of a class or interface (e.g. for local or anonymous classes).

innerName:String

the (simple) name of C. Must be null for anonymous inner classes.

access:int

the access flags of C originally declared in the source code from which this class was compiled.

Annotations
@Override
visitMethodback to summary
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions)

Overrides org.objectweb.asm.ClassVisitor.visitMethod.

Doc from org.objectweb.asm.ClassVisitor.visitMethod.

Visits a method of the class. This method must return a new MethodVisitor instance (or null) each time it is called, i.e., it should not return a previously returned visitor.

Parameters
access:int

the method's access flags (see Opcodes). This parameter also indicates if the method is synthetic and/or deprecated.

name:String

the method's name.

desc:String

the method's descriptor (see Type).

signature:String

the method's signature. May be null if the method parameters, return type and exceptions do not use generic types.

exceptions:String[]

the internal names of the method's exception classes (see Type#getInternalName()). May be null.

Returns:MethodVisitor

an object to visit the byte code of the method, or null if this class visitor is not interested in visiting the code of this method.

Annotations
@Override
org.codehaus.groovy.ast.decompiled back to summary

private Class AsmDecompiler.StubCache

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv static final Map<URI, SoftReference<ClassStub>>
map

Caches stubs per URI.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

mapback to summary
pack-priv static final Map<URI, SoftReference<ClassStub>> map

Caches stubs per URI. This cache is useful when performing multiple compilations in the same JVM/class loader and in tests. It's synchronized "just in case". Occasional misses are expected if several threads attempt to load the same class, but this shouldn't result in serious memory issues.

Constructor Detail

StubCacheback to summary
private StubCache()