|
36 | 36 | final class ClassSignature implements Constants {
|
37 | 37 | private ClassReader reader;
|
38 | 38 |
|
39 |
| - public final boolean isRuntimeClass; |
| 39 | + public final boolean isRuntimeClass, isNonPortableRuntime; |
40 | 40 | public final Set<Method> methods;
|
41 | 41 | public final Set<String> fields, signaturePolymorphicMethods;
|
42 | 42 | public final String className, superName;
|
@@ -76,6 +76,7 @@ public FieldVisitor visitField(int access, String name, String desc, String sign
|
76 | 76 | this.methods = createSet(methods);
|
77 | 77 | this.fields = createSet(fields);
|
78 | 78 | this.signaturePolymorphicMethods = createSet(signaturePolymorphicMethods);
|
| 79 | + this.isNonPortableRuntime = this.determineNonPortableRuntime(); |
79 | 80 | }
|
80 | 81 |
|
81 | 82 | /** Alternative ctor that can be used to build the information via reflection from an already loaded class. Useful for Java 9 Jigsaw. */
|
@@ -112,19 +113,28 @@ public ClassSignature(final Class<?> clazz, boolean isRuntimeClass) {
|
112 | 113 | this.methods = createSet(methods);
|
113 | 114 | this.fields = createSet(fields);
|
114 | 115 | this.signaturePolymorphicMethods = createSet(signaturePolymorphicMethods);
|
| 116 | + this.isNonPortableRuntime = this.determineNonPortableRuntime(); |
115 | 117 | }
|
116 | 118 |
|
117 | 119 | private static <T> Set<T> createSet(Set<? extends T> s) {
|
118 | 120 | return s.isEmpty() ? Collections.<T>emptySet() : Collections.<T>unmodifiableSet(s);
|
119 | 121 | }
|
| 122 | + |
| 123 | + private boolean determineNonPortableRuntime() { |
| 124 | + return isRuntimeClass && !AsmUtils.isPortableRuntimeClass(getBinaryClassName()); |
| 125 | + } |
120 | 126 |
|
121 | 127 | public ClassReader getReader() {
|
122 | 128 | if (reader == null)
|
123 |
| - throw new IllegalStateException("'" + Type.getObjectType(className).getClassName() + "' has no ClassReader, because it was already checked or is only loaded as related class."); |
| 129 | + throw new IllegalStateException("'" + getBinaryClassName() + "' has no ClassReader, because it was already checked or is only loaded as related class."); |
124 | 130 | try {
|
125 | 131 | return reader;
|
126 | 132 | } finally {
|
127 | 133 | reader = null;
|
128 | 134 | }
|
129 | 135 | }
|
| 136 | + |
| 137 | + public String getBinaryClassName() { |
| 138 | + return Type.getObjectType(className).getClassName(); |
| 139 | + } |
130 | 140 | }
|
0 commit comments