|
47 | 47 | import java.lang.reflect.Member; |
48 | 48 | import java.lang.reflect.Method; |
49 | 49 | import java.lang.reflect.Modifier; |
50 | | -import java.lang.reflect.Proxy; |
51 | 50 | import java.lang.reflect.RecordComponent; |
52 | 51 | import java.lang.reflect.Type; |
53 | 52 | import java.lang.reflect.TypeVariable; |
|
82 | 81 | import jdk.internal.vm.annotation.IntrinsicCandidate; |
83 | 82 | import jdk.internal.vm.annotation.Stable; |
84 | 83 |
|
| 84 | +import sun.invoke.util.BytecodeDescriptor; |
85 | 85 | import sun.invoke.util.Wrapper; |
86 | 86 | import sun.reflect.generics.factory.CoreReflectionFactory; |
87 | 87 | import sun.reflect.generics.factory.GenericsFactory; |
88 | 88 | import sun.reflect.generics.repository.ClassRepository; |
89 | | -import sun.reflect.generics.repository.MethodRepository; |
90 | | -import sun.reflect.generics.repository.ConstructorRepository; |
91 | 89 | import sun.reflect.generics.scope.ClassScope; |
92 | 90 | import sun.reflect.annotation.*; |
93 | 91 |
|
@@ -1435,17 +1433,10 @@ public Method getEnclosingMethod() { |
1435 | 1433 | if (!enclosingInfo.isMethod()) |
1436 | 1434 | return null; |
1437 | 1435 |
|
1438 | | - MethodRepository typeInfo = MethodRepository.make(enclosingInfo.getDescriptor(), |
1439 | | - getFactory()); |
1440 | | - Class<?> returnType = toClass(typeInfo.getReturnType()); |
1441 | | - Type [] parameterTypes = typeInfo.getParameterTypes(); |
1442 | | - Class<?>[] parameterClasses = new Class<?>[parameterTypes.length]; |
1443 | | - |
1444 | | - // Convert Types to Classes; returned types *should* |
1445 | | - // be class objects since the methodDescriptor's used |
1446 | | - // don't have generics information |
1447 | | - for(int i = 0; i < parameterClasses.length; i++) |
1448 | | - parameterClasses[i] = toClass(parameterTypes[i]); |
| 1436 | + // Descriptor already validated by VM |
| 1437 | + List<Class<?>> types = BytecodeDescriptor.parseMethod(enclosingInfo.getDescriptor(), getClassLoader()); |
| 1438 | + Class<?> returnType = types.removeLast(); |
| 1439 | + Class<?>[] parameterClasses = types.toArray(EMPTY_CLASS_ARRAY); |
1449 | 1440 |
|
1450 | 1441 | final Class<?> enclosingCandidate = enclosingInfo.getEnclosingClass(); |
1451 | 1442 | Method[] candidates = enclosingCandidate.privateGetDeclaredMethods(false); |
@@ -1564,17 +1555,10 @@ public Constructor<?> getEnclosingConstructor() { |
1564 | 1555 | if (!enclosingInfo.isConstructor()) |
1565 | 1556 | return null; |
1566 | 1557 |
|
1567 | | - ConstructorRepository typeInfo = ConstructorRepository.make(enclosingInfo.getDescriptor(), |
1568 | | - getFactory()); |
1569 | | - Type [] parameterTypes = typeInfo.getParameterTypes(); |
1570 | | - Class<?>[] parameterClasses = new Class<?>[parameterTypes.length]; |
1571 | | - |
1572 | | - // Convert Types to Classes; returned types *should* |
1573 | | - // be class objects since the methodDescriptor's used |
1574 | | - // don't have generics information |
1575 | | - for (int i = 0; i < parameterClasses.length; i++) |
1576 | | - parameterClasses[i] = toClass(parameterTypes[i]); |
1577 | | - |
| 1558 | + // Descriptor already validated by VM |
| 1559 | + List<Class<?>> types = BytecodeDescriptor.parseMethod(enclosingInfo.getDescriptor(), getClassLoader()); |
| 1560 | + types.removeLast(); |
| 1561 | + Class<?>[] parameterClasses = types.toArray(EMPTY_CLASS_ARRAY); |
1578 | 1562 |
|
1579 | 1563 | final Class<?> enclosingCandidate = enclosingInfo.getEnclosingClass(); |
1580 | 1564 | Constructor<?>[] candidates = enclosingCandidate |
@@ -1880,7 +1864,7 @@ public Class<?>[] getClasses() { |
1880 | 1864 | } |
1881 | 1865 | currentClass = currentClass.getSuperclass(); |
1882 | 1866 | } |
1883 | | - return list.toArray(new Class<?>[0]); |
| 1867 | + return list.toArray(EMPTY_CLASS_ARRAY); |
1884 | 1868 | } |
1885 | 1869 |
|
1886 | 1870 |
|
|
0 commit comments