Skip to content

Commit

Permalink
Fix truffle LibraryFactory#clearNonTruffleClasses for Java 11
Browse files Browse the repository at this point in the history
  • Loading branch information
olpaw committed Nov 5, 2019
1 parent ec5573f commit 8726932
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,10 @@ public static boolean verifyModuleVisibility(Object module, Class<?> memberClass
}
}
}

public static boolean isNonTruffleClass(Class<?> clazz) {
ClassLoader truffleClassLoader = TruffleJDKServices.class.getModule().getClassLoader();
ClassLoader classLoader = clazz.getClassLoader();
return truffleClassLoader != classLoader;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,9 @@ public static boolean verifyModuleVisibility(Object currentModule, @SuppressWarn
assert currentModule == null;
return true;
}

public static boolean isNonTruffleClass(Class<?> clazz) {
// classes on the boot loader should not be cleared
return clazz.getClassLoader() != null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.TruffleOptions;
import com.oracle.truffle.api.dsl.GeneratedBy;
import com.oracle.truffle.api.impl.TruffleJDKServices;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.NodeCost;
import com.oracle.truffle.api.nodes.NodeUtil;
Expand Down Expand Up @@ -119,8 +120,7 @@ private static void resetNativeImageState() {
private static void clearNonTruffleClasses(Map<Class<?>, ?> map) {
Class<?>[] classes = map.keySet().toArray(new Class<?>[0]);
for (Class<?> clazz : classes) {
// classes on the boot loader should not be cleared
if (clazz.getClassLoader() != null) {
if (TruffleJDKServices.isNonTruffleClass(clazz)) {
map.remove(clazz);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,12 @@ public static boolean verifyModuleVisibility(Object lookupModule, Class<?> membe
throw shouldNotReachHere();
}

/**
* Returns <code>true</code> if the class is not part of the truffle framework.
*
* @param clazz the class to check.
*/
public static boolean isNonTruffleClass(Class<?> clazz) {
throw shouldNotReachHere();
}
}

0 comments on commit 8726932

Please sign in to comment.