-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8356022: Migrate descriptor parsing from generics to BytecodeDescriptor #24978
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -47,7 +47,6 @@ | |||||||
import java.lang.reflect.Member; | ||||||||
import java.lang.reflect.Method; | ||||||||
import java.lang.reflect.Modifier; | ||||||||
import java.lang.reflect.Proxy; | ||||||||
import java.lang.reflect.RecordComponent; | ||||||||
import java.lang.reflect.Type; | ||||||||
import java.lang.reflect.TypeVariable; | ||||||||
|
@@ -82,12 +81,11 @@ | |||||||
import jdk.internal.vm.annotation.IntrinsicCandidate; | ||||||||
import jdk.internal.vm.annotation.Stable; | ||||||||
|
||||||||
import sun.invoke.util.BytecodeDescriptor; | ||||||||
import sun.invoke.util.Wrapper; | ||||||||
import sun.reflect.generics.factory.CoreReflectionFactory; | ||||||||
import sun.reflect.generics.factory.GenericsFactory; | ||||||||
import sun.reflect.generics.repository.ClassRepository; | ||||||||
import sun.reflect.generics.repository.MethodRepository; | ||||||||
import sun.reflect.generics.repository.ConstructorRepository; | ||||||||
import sun.reflect.generics.scope.ClassScope; | ||||||||
import sun.reflect.annotation.*; | ||||||||
|
||||||||
|
@@ -1437,17 +1435,10 @@ public Method getEnclosingMethod() { | |||||||
if (!enclosingInfo.isMethod()) | ||||||||
return null; | ||||||||
|
||||||||
MethodRepository typeInfo = MethodRepository.make(enclosingInfo.getDescriptor(), | ||||||||
getFactory()); | ||||||||
Class<?> returnType = toClass(typeInfo.getReturnType()); | ||||||||
Type [] parameterTypes = typeInfo.getParameterTypes(); | ||||||||
Class<?>[] parameterClasses = new Class<?>[parameterTypes.length]; | ||||||||
|
||||||||
// Convert Types to Classes; returned types *should* | ||||||||
// be class objects since the methodDescriptor's used | ||||||||
// don't have generics information | ||||||||
for(int i = 0; i < parameterClasses.length; i++) | ||||||||
parameterClasses[i] = toClass(parameterTypes[i]); | ||||||||
// Descriptor already validated by VM | ||||||||
List<Class<?>> types = BytecodeDescriptor.parseMethod(enclosingInfo.getDescriptor(), getClassLoader()); | ||||||||
Class<?> returnType = types.removeLast(); | ||||||||
Class<?>[] parameterClasses = types.toArray(EMPTY_CLASS_ARRAY); | ||||||||
|
||||||||
final Class<?> enclosingCandidate = enclosingInfo.getEnclosingClass(); | ||||||||
Method[] candidates = enclosingCandidate.privateGetDeclaredMethods(false); | ||||||||
|
@@ -1566,17 +1557,10 @@ public Constructor<?> getEnclosingConstructor() { | |||||||
if (!enclosingInfo.isConstructor()) | ||||||||
return null; | ||||||||
|
||||||||
ConstructorRepository typeInfo = ConstructorRepository.make(enclosingInfo.getDescriptor(), | ||||||||
getFactory()); | ||||||||
Type [] parameterTypes = typeInfo.getParameterTypes(); | ||||||||
Class<?>[] parameterClasses = new Class<?>[parameterTypes.length]; | ||||||||
|
||||||||
// Convert Types to Classes; returned types *should* | ||||||||
// be class objects since the methodDescriptor's used | ||||||||
// don't have generics information | ||||||||
for (int i = 0; i < parameterClasses.length; i++) | ||||||||
parameterClasses[i] = toClass(parameterTypes[i]); | ||||||||
|
||||||||
// Descriptor already validated by VM | ||||||||
List<Class<?>> types = BytecodeDescriptor.parseMethod(enclosingInfo.getDescriptor(), getClassLoader()); | ||||||||
types.removeLast(); | ||||||||
Class<?>[] parameterClasses = types.toArray(EMPTY_CLASS_ARRAY); | ||||||||
|
||||||||
final Class<?> enclosingCandidate = enclosingInfo.getEnclosingClass(); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Here the local variable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This patch intentionally did not change this part - and this part can get much more in-depth optimization; for example, arrayContentsEq can be shared for all |
||||||||
Constructor<?>[] candidates = enclosingCandidate | ||||||||
|
@@ -1882,7 +1866,7 @@ public Class<?>[] getClasses() { | |||||||
} | ||||||||
currentClass = currentClass.getSuperclass(); | ||||||||
} | ||||||||
return list.toArray(new Class<?>[0]); | ||||||||
return list.toArray(EMPTY_CLASS_ARRAY); | ||||||||
} | ||||||||
|
||||||||
|
||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here the type of parameterClasses is very clear, or you can use var