Skip to content

Commit 23e9ca9

Browse files
Type resolution failures from the verifier shouldn't stick
1 parent 012ed95 commit 23e9ca9

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

espresso-shared/src/com.oracle.truffle.espresso.shared/src/com/oracle/truffle/espresso/shared/meta/TypeAccess.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ default boolean isJavaLangObject() {
202202

203203
/**
204204
* Resolves a class in the runtime constant pool of this type, then returns it. Further calls to
205-
* this method with the same cpi should not trigger class loading.
205+
* this method with the same cpi should not trigger class loading. Resolution errors should not
206+
* be saved in the constant pool.
206207
*
207208
* @param cpi The constant pool index in which to find the class constant
208209
* @throws IllegalArgumentException If there is no

espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/constantpool/RuntimeConstantPool.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,20 @@ private ResolvedConstant outOfLockResolvedAt(ObjectKlass accessingKlass, int ind
112112
* Returns the resolved, non-primitive, constant pool entry.
113113
*/
114114
public ResolvedConstant resolvedAt(ObjectKlass accessingKlass, int index) {
115+
return resolvedAt(accessingKlass, index, true);
116+
}
117+
118+
public ResolvedConstant resolvedAt(ObjectKlass accessingKlass, int index, boolean allowStickyFailures) {
115119
ResolvedConstant c = resolvedConstants[index];
116120
if (c == null) {
117121
CompilerDirectives.transferToInterpreterAndInvalidate();
118122
synchronized (this) {
119123
c = resolvedConstants[index];
120124
if (c == null) {
121-
resolvedConstants[index] = c = resolve(index, accessingKlass);
125+
c = resolve(index, accessingKlass);
126+
if (allowStickyFailures || c.isSuccess()) {
127+
resolvedConstants[index] = c;
128+
}
122129
}
123130
}
124131
}
@@ -136,7 +143,11 @@ private ResolvedConstant resolvedAtNoCache(ObjectKlass accessingKlass, int index
136143
}
137144

138145
public Klass resolvedKlassAt(ObjectKlass accessingKlass, int index) {
139-
ResolvedClassConstant resolved = (ResolvedClassConstant) resolvedAt(accessingKlass, index);
146+
return resolvedKlassAt(accessingKlass, index, true);
147+
}
148+
149+
public Klass resolvedKlassAt(ObjectKlass accessingKlass, int index, boolean allowStickyFailures) {
150+
ResolvedClassConstant resolved = (ResolvedClassConstant) resolvedAt(accessingKlass, index, allowStickyFailures);
140151
return (Klass) resolved.value();
141152
}
142153

espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/impl/Klass.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1925,7 +1925,7 @@ public final boolean isMagicAccessor() {
19251925
public final Klass resolveClassConstantInPool(int cpi) {
19261926
if (this instanceof ObjectKlass objectKlass) {
19271927
try {
1928-
return objectKlass.getConstantPool().resolvedKlassAt(objectKlass, cpi);
1928+
return objectKlass.getConstantPool().resolvedKlassAt(objectKlass, cpi, false);
19291929
} catch (ClassCastException | IndexOutOfBoundsException e) {
19301930
throw new IllegalArgumentException("No ClassConstant at constant pool index " + cpi);
19311931
}

0 commit comments

Comments
 (0)