|
24 | 24 | */
|
25 | 25 | package jdk.graal.compiler.libgraal;
|
26 | 26 |
|
| 27 | +import java.util.Collections; |
| 28 | +import java.util.Set; |
| 29 | + |
27 | 30 | import com.oracle.svm.core.annotate.Alias;
|
28 | 31 | import com.oracle.svm.core.annotate.RecomputeFieldValue;
|
| 32 | +import com.oracle.svm.core.annotate.Substitute; |
29 | 33 | import com.oracle.svm.core.annotate.TargetClass;
|
30 | 34 |
|
31 | 35 | class LibGraalSubstitutions {
|
@@ -54,4 +58,49 @@ static final class Target_jdk_vm_ci_hotspot_Cleaner {
|
54 | 58 | @Alias
|
55 | 59 | public static native void clean();
|
56 | 60 | }
|
| 61 | + |
| 62 | + /* |
| 63 | + * There are no String-based class-lookups happening at libgraal runtime. Thus, we can safely |
| 64 | + * prune all classloading-logic out of the image. |
| 65 | + */ |
| 66 | + @TargetClass(value = java.lang.Class.class, onlyWith = LibGraalFeature.IsEnabled.class) |
| 67 | + static final class Target_java_lang_Class { |
| 68 | + @Substitute |
| 69 | + public static Class<?> forName(String name, boolean initialize, ClassLoader loader) |
| 70 | + throws ClassNotFoundException { |
| 71 | + throw new ClassNotFoundException(name); |
| 72 | + } |
| 73 | + |
| 74 | + @Substitute |
| 75 | + private static Class<?> forName(String className, Class<?> caller) |
| 76 | + throws ClassNotFoundException { |
| 77 | + throw new ClassNotFoundException(className); |
| 78 | + } |
| 79 | + |
| 80 | + @Substitute |
| 81 | + public static Class<?> forName(Module module, String name) { |
| 82 | + return null; |
| 83 | + } |
| 84 | + } |
| 85 | + |
| 86 | + @TargetClass(value = java.lang.Module.class, onlyWith = LibGraalFeature.IsEnabled.class) |
| 87 | + static final class Target_java_lang_Module { |
| 88 | + @Substitute |
| 89 | + public Set<String> getPackages() { |
| 90 | + return Collections.emptySet(); |
| 91 | + } |
| 92 | + } |
| 93 | + |
| 94 | + @TargetClass(value = java.lang.ClassLoader.class, onlyWith = LibGraalFeature.IsEnabled.class) |
| 95 | + static final class Target_java_lang_ClassLoader { |
| 96 | + @Substitute |
| 97 | + public Class<?> loadClass(String name) throws ClassNotFoundException { |
| 98 | + throw new ClassNotFoundException(name); |
| 99 | + } |
| 100 | + |
| 101 | + @Substitute |
| 102 | + static Class<?> findBootstrapClassOrNull(String name) { |
| 103 | + return null; |
| 104 | + } |
| 105 | + } |
57 | 106 | }
|
0 commit comments