Top Description Inners Fields Constructors Methods
org.springframework.cglib.proxy

pack-priv Class BridgeMethodResolver

extends Object
Class Inheritance
Annotations
@SuppressWarnings:rawtypes, unchecked
Imports
java.io.IOException, .InputStream, java.util.HashMap, .Iterator, .Map, .Set, org.springframework.asm.ClassReader, .ClassVisitor, .MethodVisitor, .Opcodes, org.springframework.cglib.core.Constants, .Signature

Uses bytecode reflection to figure out the targets of all bridge methods that use invokespecial and invokeinterface, so that we can later rewrite them to use invokevirtual.

For interface bridges, using invokesuper will fail since the method being bridged to is in a superinterface, not a superclass. Starting in Java 8, javac emits default bridge methods in interfaces, which use invokeinterface to bridge to the target method.

Author
[email protected] (Sam Berlin)

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final ClassLoader
private final Map<K, V>

Constructor Summary

AccessConstructor and Description
public
BridgeMethodResolver(Map<K, V> declToBridge, ClassLoader classLoader)

Method Summary

Modifier and TypeMethod and Description
public Map<K, V>
resolveAll()

Finds all bridge methods that are being called with invokespecial & returns them.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

classLoaderback to summary
private final ClassLoader classLoader
declToBridgeback to summary
private final Map<K, V> declToBridge

Constructor Detail

BridgeMethodResolverback to summary
public BridgeMethodResolver(Map<K, V> declToBridge, ClassLoader classLoader)

Method Detail

resolveAllback to summary
public Map<K, V> resolveAll()

Finds all bridge methods that are being called with invokespecial & returns them.

org.springframework.cglib.proxy back to summary

private Class BridgeMethodResolver.BridgedFinder

extends ClassVisitor
Class Inheritance

Field Summary

Modifier and TypeField and Description
private Signature
private Set<E>
private Map<K, V>
Inherited from org.springframework.asm.ClassVisitor:
apicv

Constructor Summary

AccessConstructor and Description
pack-priv
BridgedFinder(Set<E> eligibleMethods, Map<K, V> resolved)

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.
interfaces
)

Overrides org.springframework.asm.ClassVisitor.visit.

Visits the header of the 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.springframework.asm.ClassVisitor.visitMethod.

Visits a method of the class.

Inherited from org.springframework.asm.ClassVisitor:
getDelegatevisitAnnotationvisitAttributevisitEndvisitFieldvisitInnerClassvisitModulevisitNestHostvisitNestMembervisitOuterClassvisitPermittedSubclassvisitRecordComponentvisitSourcevisitTypeAnnotation

Field Detail

currentMethodback to summary
private Signature currentMethod
eligibleMethodsback to summary
private Set<E> eligibleMethods
resolvedback to summary
private Map<K, V> resolved

Constructor Detail

BridgedFinderback to summary
pack-priv BridgedFinder(Set<E> eligibleMethods, Map<K, V> resolved)

Method Detail

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

Overrides org.springframework.asm.ClassVisitor.visit.

Doc from org.springframework.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.

interfaces:String[]

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

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

Overrides org.springframework.asm.ClassVisitor.visitMethod.

Doc from org.springframework.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