Skip to content

Commit

Permalink
[GR-60869] Adopt "JDK-8346986: Remove ASM from java.base"
Browse files Browse the repository at this point in the history
PullRequest: graal/19755
  • Loading branch information
zapster committed Jan 13, 2025
2 parents daea77d + 6733496 commit d7d4ddb
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 45 deletions.
3 changes: 3 additions & 0 deletions substratevm/mx.substratevm/mx_substratevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@

import sys

# re-export custom mx project classes, so they can be used from suite.py
from mx_sdk_shaded import ShadedLibraryProject # pylint: disable=unused-import

suite = mx.suite('substratevm')
svmSuites = [suite]

Expand Down
35 changes: 31 additions & 4 deletions substratevm/mx.substratevm/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,36 @@
"jacoco" : "include",
},

# This shaded ASM project is just a quickfix.
# Eventually, we should migrate to the Classfile API [JDK-8294982] (GR-61102).
"com.oracle.svm.shaded.org.objectweb.asm": {
# Shadowed ASM libraries (org.ow2.asm:asm,asm-tree)
"subDir" : "src",
"sourceDirs" : ["src"],
"javaCompliance" : "17+",
"spotbugsIgnoresGenerated" : True,
"shadedDependencies" : [
"compiler:ASM_9.7.1",
"compiler:ASM_TREE_9.7.1",
],
"class" : "ShadedLibraryProject",
"shade" : {
"packages" : {
"org.objectweb.asm" : "com.oracle.svm.shaded.org.objectweb.asm",
},
"exclude" : [
"META-INF/MANIFEST.MF",
"**/package.html",
],
},
"description" : "ASM library shadowed for Native Iamge.",
# We need to force javac because the generated sources in this project produce warnings in JDT.
"forceJavac" : "true",
"javac.lint.overrides" : "none",
"jacoco" : "exclude",
"graalCompilerSourceEdition": "ignore",
},

"com.oracle.svm.processor" : {
"subDir" : "src",
"sourceDirs" : ["src"],
Expand All @@ -277,6 +307,7 @@
],
"dependencies": [
"com.oracle.svm.common",
"com.oracle.svm.shaded.org.objectweb.asm",
],
"requires" : [
"java.compiler",
Expand Down Expand Up @@ -318,7 +349,6 @@
"jdk.internal.vm",
"jdk.internal.vm.annotation",
"jdk.internal.util",
"jdk.internal.org.objectweb.asm",
],
"java.management": [
"com.sun.jmx.mbeanserver",
Expand Down Expand Up @@ -665,7 +695,6 @@
"jdk.internal.loader",
"jdk.internal.misc",
"jdk.internal.vm.annotation",
"jdk.internal.org.objectweb.asm",
"sun.net.www",
"sun.reflect.annotation",
"sun.security.jca",
Expand Down Expand Up @@ -1501,7 +1530,6 @@
"requiresConcealed" : {
"java.base" : [
"jdk.internal.loader",
"jdk.internal.org.objectweb.asm",
],
},
"checkstyle": "com.oracle.svm.hosted",
Expand Down Expand Up @@ -1771,7 +1799,6 @@
"sun.security.ssl",
"com.sun.crypto.provider",
"sun.reflect.generics.repository",
"jdk.internal.org.objectweb.asm",
"sun.util.locale.provider",
"sun.util.cldr",
"sun.util.resources",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ public final class PointsToAnalyzer {
ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "java.base", "jdk.internal.loader");
ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "java.base", "jdk.internal.misc");
ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "java.base", "sun.text.spi");
ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "java.base", "jdk.internal.org.objectweb.asm");
ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "java.base", "sun.reflect.annotation");
ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "java.base", "sun.security.jca");
ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "jdk.jdeps", "com.sun.tools.classfile");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@
import com.oracle.svm.core.reflect.serialize.SerializationSupport;
import com.oracle.svm.core.util.ImageHeapMap;
import com.oracle.svm.core.util.VMError;
import com.oracle.svm.shaded.org.objectweb.asm.ClassReader;
import com.oracle.svm.shaded.org.objectweb.asm.ClassVisitor;
import com.oracle.svm.shaded.org.objectweb.asm.ClassWriter;
import com.oracle.svm.shaded.org.objectweb.asm.MethodVisitor;
import com.oracle.svm.shaded.org.objectweb.asm.Opcodes;
import com.oracle.svm.util.ClassUtil;

import jdk.graal.compiler.api.replacements.Fold;
import jdk.graal.compiler.java.LambdaUtils;
import jdk.graal.compiler.options.Option;
import jdk.graal.compiler.util.Digest;
import jdk.internal.org.objectweb.asm.ClassReader;
import jdk.internal.org.objectweb.asm.ClassVisitor;
import jdk.internal.org.objectweb.asm.ClassWriter;
import jdk.internal.org.objectweb.asm.MethodVisitor;
import jdk.internal.org.objectweb.asm.Opcodes;

public final class PredefinedClassesSupport {
public static final class Options {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@
package com.oracle.svm.diagnosticsagent;

import com.oracle.svm.jvmtiagentbase.JvmtiAgentBase;

import jdk.internal.org.objectweb.asm.ClassVisitor;
import jdk.internal.org.objectweb.asm.ClassWriter;
import jdk.internal.org.objectweb.asm.MethodVisitor;
import jdk.internal.org.objectweb.asm.Opcodes;
import com.oracle.svm.shaded.org.objectweb.asm.ClassVisitor;
import com.oracle.svm.shaded.org.objectweb.asm.ClassWriter;
import com.oracle.svm.shaded.org.objectweb.asm.MethodVisitor;
import com.oracle.svm.shaded.org.objectweb.asm.Opcodes;

public class ClinitGenerationVisitor extends ClassVisitor {
private boolean hasClinit = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@
import com.oracle.svm.jvmtiagentbase.jvmti.JvmtiEventCallbacks;
import com.oracle.svm.jvmtiagentbase.jvmti.JvmtiEventMode;
import com.oracle.svm.jvmtiagentbase.jvmti.JvmtiInterface;

import jdk.internal.org.objectweb.asm.ClassReader;
import jdk.internal.org.objectweb.asm.ClassWriter;
import com.oracle.svm.shaded.org.objectweb.asm.ClassReader;
import com.oracle.svm.shaded.org.objectweb.asm.ClassWriter;

/**
* JVMTI agent that provides diagnostics information that helps resolve native-image build failures.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
*/
package com.oracle.svm.hosted;

import static jdk.internal.org.objectweb.asm.Opcodes.ACC_FINAL;
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_PUBLIC;
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_STATIC;
import static com.oracle.svm.shaded.org.objectweb.asm.Opcodes.ACC_FINAL;
import static com.oracle.svm.shaded.org.objectweb.asm.Opcodes.ACC_PUBLIC;
import static com.oracle.svm.shaded.org.objectweb.asm.Opcodes.ACC_STATIC;

import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -56,16 +56,15 @@
import com.oracle.svm.hosted.FeatureImpl.AfterRegistrationAccessImpl;
import com.oracle.svm.hosted.config.ConfigurationParserUtils;
import com.oracle.svm.hosted.reflect.ReflectionFeature;
import com.oracle.svm.util.ModuleSupport;
import com.oracle.svm.shaded.org.objectweb.asm.ClassReader;
import com.oracle.svm.shaded.org.objectweb.asm.ClassVisitor;
import com.oracle.svm.shaded.org.objectweb.asm.ClassWriter;
import com.oracle.svm.shaded.org.objectweb.asm.FieldVisitor;
import com.oracle.svm.shaded.org.objectweb.asm.MethodVisitor;
import com.oracle.svm.shaded.org.objectweb.asm.Opcodes;

import jdk.graal.compiler.java.LambdaUtils;
import jdk.graal.compiler.util.Digest;
import jdk.internal.org.objectweb.asm.ClassReader;
import jdk.internal.org.objectweb.asm.ClassVisitor;
import jdk.internal.org.objectweb.asm.ClassWriter;
import jdk.internal.org.objectweb.asm.FieldVisitor;
import jdk.internal.org.objectweb.asm.MethodVisitor;
import jdk.internal.org.objectweb.asm.Opcodes;

@AutomaticallyRegisteredFeature
public class ClassPredefinitionFeature implements InternalFeature {
Expand Down Expand Up @@ -97,7 +96,6 @@ public void afterRegistration(AfterRegistrationAccess arg) {
ConfigurationParserUtils.parseAndRegisterConfigurations(parser, access.getImageClassLoader(), "class predefinition",
ConfigurationFiles.Options.PredefinedClassesConfigurationFiles, ConfigurationFiles.Options.PredefinedClassesConfigurationResources,
ConfigurationFile.PREDEFINED_CLASSES_NAME.getFileName());
ModuleSupport.accessPackagesToClass(ModuleSupport.Access.EXPORT, PredefinedClassesSupport.class, false, "java.base", "jdk.internal.org.objectweb.asm");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,6 @@ public static void setModuleAccesses() {
ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "java.base", "jdk.internal.loader");
ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "java.base", "jdk.internal.misc");
ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "java.base", "sun.text.spi");
ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "java.base", "jdk.internal.org.objectweb.asm");
ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "java.base", "sun.reflect.annotation");
ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "java.base", "sun.security.jca");
ModuleSupport.accessPackagesToClass(ModuleSupport.Access.OPEN, null, false, "jdk.jdeps", "com.sun.tools.classfile");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@
*/
package com.oracle.svm.hosted.heap;

import static jdk.internal.org.objectweb.asm.Opcodes.ACC_FINAL;
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_PRIVATE;
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_PUBLIC;
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_SUPER;
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_SYNTHETIC;
import static jdk.internal.org.objectweb.asm.Opcodes.ACONST_NULL;
import static jdk.internal.org.objectweb.asm.Opcodes.ALOAD;
import static jdk.internal.org.objectweb.asm.Opcodes.ARETURN;
import static jdk.internal.org.objectweb.asm.Opcodes.INVOKESPECIAL;
import static jdk.internal.org.objectweb.asm.Opcodes.PUTFIELD;
import static jdk.internal.org.objectweb.asm.Opcodes.RETURN;
import static jdk.internal.org.objectweb.asm.Opcodes.V11;
import static com.oracle.svm.shaded.org.objectweb.asm.Opcodes.ACC_FINAL;
import static com.oracle.svm.shaded.org.objectweb.asm.Opcodes.ACC_PRIVATE;
import static com.oracle.svm.shaded.org.objectweb.asm.Opcodes.ACC_PUBLIC;
import static com.oracle.svm.shaded.org.objectweb.asm.Opcodes.ACC_SUPER;
import static com.oracle.svm.shaded.org.objectweb.asm.Opcodes.ACC_SYNTHETIC;
import static com.oracle.svm.shaded.org.objectweb.asm.Opcodes.ACONST_NULL;
import static com.oracle.svm.shaded.org.objectweb.asm.Opcodes.ALOAD;
import static com.oracle.svm.shaded.org.objectweb.asm.Opcodes.ARETURN;
import static com.oracle.svm.shaded.org.objectweb.asm.Opcodes.INVOKESPECIAL;
import static com.oracle.svm.shaded.org.objectweb.asm.Opcodes.PUTFIELD;
import static com.oracle.svm.shaded.org.objectweb.asm.Opcodes.RETURN;
import static com.oracle.svm.shaded.org.objectweb.asm.Opcodes.V11;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
Expand Down Expand Up @@ -64,10 +64,10 @@
import com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl;
import com.oracle.svm.hosted.FeatureImpl.DuringSetupAccessImpl;
import com.oracle.svm.hosted.NativeImageSystemClassLoader;
import com.oracle.svm.shaded.org.objectweb.asm.ClassWriter;
import com.oracle.svm.shaded.org.objectweb.asm.Type;
import com.oracle.svm.util.ReflectionUtil;

import jdk.internal.org.objectweb.asm.ClassWriter;
import jdk.internal.org.objectweb.asm.Type;
import jdk.vm.ci.meta.JavaKind;

/** Support for preparing the creation of {@link Pod} objects during the image build. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
import com.oracle.svm.hosted.code.FactoryMethodSupport;
import com.oracle.svm.hosted.code.SubstrateCompilationDirectives;
import com.oracle.svm.hosted.nodes.DeoptProxyNode;
import com.oracle.svm.shaded.org.objectweb.asm.Opcodes;
import com.oracle.svm.util.ReflectionUtil;

import jdk.graal.compiler.api.replacements.Fold;
Expand Down Expand Up @@ -131,7 +132,6 @@
import jdk.graal.compiler.phases.OptimisticOptimizations;
import jdk.graal.compiler.replacements.SnippetTemplate;
import jdk.internal.access.SharedSecrets;
import jdk.internal.org.objectweb.asm.Opcodes;
import jdk.vm.ci.meta.ConstantPool.BootstrapMethodInvocation;
import jdk.vm.ci.meta.JavaConstant;
import jdk.vm.ci.meta.JavaField;
Expand Down

0 comments on commit d7d4ddb

Please sign in to comment.