diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/dbws/SOAPResponseClassLoader.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/dbws/SOAPResponseClassLoader.java index b5ee39abbcd..2f4fe30d26a 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/dbws/SOAPResponseClassLoader.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/dbws/SOAPResponseClassLoader.java @@ -58,12 +58,12 @@ protected byte[] generateClassBytes(String className) { * } */ ClassWriter cw = new EclipseLinkASMClassWriter(); - cw.visit(Opcodes.valueInt("ACC_PUBLIC") + Opcodes.valueInt("ACC_SUPER"), className, null, SOAP_RESPONSE_CLASSNAME_SLASHES, null); + cw.visit(Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, className, null, SOAP_RESPONSE_CLASSNAME_SLASHES, null); - MethodVisitor mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "", "()V", null, null); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), SOAP_RESPONSE_CLASSNAME_SLASHES, "", "()V", false); - mv.visitInsn(Opcodes.valueInt("RETURN")); + MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "", "()V", null, null); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, SOAP_RESPONSE_CLASSNAME_SLASHES, "", "()V", false); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(0, 0); mv.visitEnd(); diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/XRClassWriter.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/XRClassWriter.java index 1e52a881e40..5e3e4895f4e 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/XRClassWriter.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/XRClassWriter.java @@ -67,44 +67,44 @@ public byte[] writeClass(DynamicClassLoader loader, String className) throws Cla // special-case: build sub-class of XRDynamicEntityCollection if (className.endsWith(COLLECTION_WRAPPER_SUFFIX)) { - cw.visit(Opcodes.valueInt("ACC_PUBLIC") + Opcodes.valueInt("ACC_SUPER"), classNameAsSlashes, null, XR_DYNAMIC_ENTITY_COLLECTION_CLASSNAME_SLASHES, null); - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), INIT, "()V", null, null); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), XR_DYNAMIC_ENTITY_COLLECTION_CLASSNAME_SLASHES, INIT, "()V", false); - mv.visitInsn(Opcodes.valueInt("RETURN")); + cw.visit(Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, classNameAsSlashes, null, XR_DYNAMIC_ENTITY_COLLECTION_CLASSNAME_SLASHES, null); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC, INIT, "()V", null, null); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, XR_DYNAMIC_ENTITY_COLLECTION_CLASSNAME_SLASHES, INIT, "()V", false); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(0, 0); mv.visitEnd(); } else { // public class Foo extends XRDynamicEntity { - cw.visit(Opcodes.valueInt("ACC_PUBLIC") + Opcodes.valueInt("ACC_SUPER"), classNameAsSlashes, null, XR_DYNAMIC_ENTITY_CLASSNAME_SLASHES, null); + cw.visit(Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, classNameAsSlashes, null, XR_DYNAMIC_ENTITY_CLASSNAME_SLASHES, null); // public static XRDynamicPropertiesManager DPM = new // XRDynamicPropertiesManager(); - cw.visitField(Opcodes.valueInt("ACC_PUBLIC") + Opcodes.valueInt("ACC_STATIC"), PROPERTIES_MANAGER_FIELD, "L" + XR_DYNAMIC_PROPERTIES_MANAGER_CLASSNAME_SLASHES + ";", null, null); - - mv = cw.visitMethod(Opcodes.valueInt("ACC_STATIC"), CLINIT, "()V", null, null); - mv.visitTypeInsn(Opcodes.valueInt("NEW"), XR_DYNAMIC_PROPERTIES_MANAGER_CLASSNAME_SLASHES); - mv.visitInsn(Opcodes.valueInt("DUP")); - mv.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), XR_DYNAMIC_PROPERTIES_MANAGER_CLASSNAME_SLASHES, INIT, "()V", false); - mv.visitFieldInsn(Opcodes.valueInt("PUTSTATIC"), classNameAsSlashes, PROPERTIES_MANAGER_FIELD, "L" + XR_DYNAMIC_PROPERTIES_MANAGER_CLASSNAME_SLASHES + ";"); - mv.visitInsn(Opcodes.valueInt("RETURN")); + cw.visitField(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, PROPERTIES_MANAGER_FIELD, "L" + XR_DYNAMIC_PROPERTIES_MANAGER_CLASSNAME_SLASHES + ";", null, null); + + mv = cw.visitMethod(Opcodes.ACC_STATIC, CLINIT, "()V", null, null); + mv.visitTypeInsn(Opcodes.NEW, XR_DYNAMIC_PROPERTIES_MANAGER_CLASSNAME_SLASHES); + mv.visitInsn(Opcodes.DUP); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, XR_DYNAMIC_PROPERTIES_MANAGER_CLASSNAME_SLASHES, INIT, "()V", false); + mv.visitFieldInsn(Opcodes.PUTSTATIC, classNameAsSlashes, PROPERTIES_MANAGER_FIELD, "L" + XR_DYNAMIC_PROPERTIES_MANAGER_CLASSNAME_SLASHES + ";"); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(0, 0); mv.visitEnd(); // public Foo() { // super(); // } - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), INIT, "()V", null, null); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), XR_DYNAMIC_ENTITY_CLASSNAME_SLASHES, INIT, "()V", false); - mv.visitInsn(Opcodes.valueInt("RETURN")); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC, INIT, "()V", null, null); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, XR_DYNAMIC_ENTITY_CLASSNAME_SLASHES, INIT, "()V", false); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(0, 0); mv.visitEnd(); // public XRDynamicPropertiesManager fetchPropertiesManager() { - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "fetchPropertiesManager", "()L" + XR_DYNAMIC_PROPERTIES_MANAGER_CLASSNAME_SLASHES + ";", null, null); - mv.visitFieldInsn(Opcodes.valueInt("GETSTATIC"), classNameAsSlashes, PROPERTIES_MANAGER_FIELD, "L" + XR_DYNAMIC_PROPERTIES_MANAGER_CLASSNAME_SLASHES + ";"); - mv.visitInsn(Opcodes.valueInt("ARETURN")); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "fetchPropertiesManager", "()L" + XR_DYNAMIC_PROPERTIES_MANAGER_CLASSNAME_SLASHES + ";", null, null); + mv.visitFieldInsn(Opcodes.GETSTATIC, classNameAsSlashes, PROPERTIES_MANAGER_FIELD, "L" + XR_DYNAMIC_PROPERTIES_MANAGER_CLASSNAME_SLASHES + ";"); + mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(0, 0); mv.visitEnd(); } diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/asm/ASMFactory.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/asm/ASMFactory.java index 0ff0ba62e66..03f722dbec8 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/asm/ASMFactory.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/asm/ASMFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023,2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -41,8 +41,8 @@ public class ASMFactory { private final static String ASM_ECLIPSELINK_CLASS_VISITOR = "org.eclipse.persistence.internal.libraries.asm.ClassVisitor"; //Should be changed in case of ASM upgrade - public final static int ASM_API_SELECTED = Opcodes.valueInt("ASM9"); - public final static int JAVA_CLASS_VERSION = Opcodes.valueInt("V1_8"); + public final static int ASM_API_SELECTED = Opcodes.ASM9; + public final static int JAVA_CLASS_VERSION = Opcodes.V1_8; public final static int JAVA_CLASS_LATEST_VERSION = ASMFactory.getLatestOPCodeVersion(); public static AnnotationVisitor createAnnotationVisitor(final int api) { diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/asm/ClassReader.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/asm/ClassReader.java index c5a1418cfdb..841d7b30bfa 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/asm/ClassReader.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/asm/ClassReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -14,13 +14,14 @@ // Oracle - initial API and implementation package org.eclipse.persistence.asm; +import org.eclipse.persistence.asm.internal.Util; + import java.util.HashMap; import java.util.Map; -import org.eclipse.persistence.asm.internal.Util; - public abstract class ClassReader { + //This block must be first - begin private final static String ASM_CLASSREADER_ECLIPSELINK = "org.eclipse.persistence.internal.libraries.asm.ClassReader"; private final static String ASM_CLASSREADER_OW2 = "org.objectweb.asm.ClassReader"; @@ -30,8 +31,13 @@ public abstract class ClassReader { ASM_CLASSREADER_MAP.put(ASMFactory.ASM_SERVICE_OW2, ASM_CLASSREADER_OW2); ASM_CLASSREADER_MAP.put(ASMFactory.ASM_SERVICE_ECLIPSELINK, ASM_CLASSREADER_ECLIPSELINK); } + //This block must be first - end + + public static final int SKIP_CODE = valueInt("SKIP_CODE"); + public static final int SKIP_DEBUG = valueInt("SKIP_DEBUG"); + public static final int SKIP_FRAMES = valueInt("SKIP_FRAMES"); - public static int valueInt(String fieldName) { + private static int valueInt(String fieldName) { return ((int) Util.getFieldValue(ASM_CLASSREADER_MAP, fieldName, Integer.TYPE)); } diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/asm/ClassWriter.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/asm/ClassWriter.java index 6a87d81875d..54ae1b49ca1 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/asm/ClassWriter.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/asm/ClassWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -14,13 +14,14 @@ // Oracle - initial API and implementation package org.eclipse.persistence.asm; +import org.eclipse.persistence.asm.internal.Util; + import java.util.HashMap; import java.util.Map; -import org.eclipse.persistence.asm.internal.Util; - public abstract class ClassWriter extends ClassVisitor { + //This block must be first - begin private final static String ASM_CLASSWRITER_ECLIPSELINK = "org.eclipse.persistence.internal.libraries.asm.ClassWriter"; private final static String ASM_CLASSWRITER_OW2 = "org.objectweb.asm.ClassWriter"; @@ -30,7 +31,9 @@ public abstract class ClassWriter extends ClassVisitor { ASM_CLASSWRITER_MAP.put(ASMFactory.ASM_SERVICE_OW2, ASM_CLASSWRITER_OW2); ASM_CLASSWRITER_MAP.put(ASMFactory.ASM_SERVICE_ECLIPSELINK, ASM_CLASSWRITER_ECLIPSELINK); } + //This block must be first - end + public static final int COMPUTE_FRAMES = valueInt("COMPUTE_FRAMES"); private ClassWriter cw; protected ClassWriter customClassWriter; @@ -58,7 +61,7 @@ public ClassWriter getInternal() { return cw; } - public static int valueInt(String fieldName) { + private static int valueInt(String fieldName) { return ((int) Util.getFieldValue(ASM_CLASSWRITER_MAP, fieldName, Integer.TYPE)); } diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/asm/EclipseLinkASMClassWriter.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/asm/EclipseLinkASMClassWriter.java index 8a5000c7936..28ca34d10a0 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/asm/EclipseLinkASMClassWriter.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/asm/EclipseLinkASMClassWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023,2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -23,7 +23,7 @@ public class EclipseLinkASMClassWriter extends ClassWriter { private ClassWriter classWriter; public EclipseLinkASMClassWriter() { - this(ClassWriter.valueInt("COMPUTE_FRAMES")); + this(ClassWriter.COMPUTE_FRAMES); } public EclipseLinkASMClassWriter(final int flags) { diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/asm/Opcodes.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/asm/Opcodes.java index fcfc2a0fceb..40de221d761 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/asm/Opcodes.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/asm/Opcodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023,2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -22,6 +22,7 @@ public class Opcodes { + //This block must be first - begin private final static String ASM_OPCCODES_ECLIPSELINK = "org.eclipse.persistence.internal.libraries.asm.Opcodes"; private final static String ASM_OPCCODES_OW2 = "org.objectweb.asm.Opcodes"; @@ -31,13 +32,68 @@ public class Opcodes { ASM_OPCCODES_MAP.put(ASMFactory.ASM_SERVICE_OW2, ASM_OPCCODES_OW2); ASM_OPCCODES_MAP.put(ASMFactory.ASM_SERVICE_ECLIPSELINK, ASM_OPCCODES_ECLIPSELINK); } + //This block must be first - end + + public static final int AASTORE = valueInt("AASTORE"); + public static final int ACC_ENUM = valueInt("ACC_ENUM"); + public static final int ACC_FINAL = valueInt("ACC_FINAL"); + public static final int ACC_INTERFACE = valueInt("ACC_INTERFACE"); + public static final int ACC_PRIVATE = valueInt("ACC_PRIVATE"); + public static final int ACC_PROTECTED = valueInt("ACC_PROTECTED"); + public static final int ACC_PUBLIC = valueInt("ACC_PUBLIC"); + public static final int ACC_STATIC = valueInt("ACC_STATIC"); + public static final int ACC_SUPER = valueInt("ACC_SUPER"); + public static final int ACC_SYNTHETIC = valueInt("ACC_SYNTHETIC"); + public static final int ACC_TRANSIENT = valueInt("ACC_TRANSIENT"); + public static final int ACONST_NULL = valueInt("ACONST_NULL"); + public static final int ALOAD = valueInt("ALOAD"); + public static final int ANEWARRAY = valueInt("ANEWARRAY"); + public static final int ARETURN = valueInt("ARETURN"); + public static final int ASM9 = Opcodes.valueInt("ASM9"); + public static final int ASTORE = valueInt("ASTORE"); + public static final int BIPUSH = valueInt("BIPUSH"); + public static final int CHECKCAST = valueInt("CHECKCAST"); + public static final int DUP = valueInt("DUP"); + public static final int F_SAME = valueInt("F_SAME"); + public static final int GETFIELD = valueInt("GETFIELD"); + public static final int GETSTATIC = valueInt("GETSTATIC"); + public static final int GOTO = valueInt("GOTO"); + public static final int ICONST_0 = valueInt("ICONST_0"); + public static final int ICONST_1 = valueInt("ICONST_1"); + public static final int ICONST_2 = valueInt("ICONST_2"); + public static final int ICONST_3 = valueInt("ICONST_3"); + public static final int ICONST_4 = valueInt("ICONST_4"); + public static final int ICONST_5 = valueInt("ICONST_5"); + public static final int IF_ACMPEQ = valueInt("IF_ACMPEQ"); + public static final int IF_ACMPNE = valueInt("IF_ACMPNE"); + public static final int IFEQ = valueInt("IFEQ"); + public static final int IFNE = valueInt("IFNE"); + public static final int IFNONNULL = valueInt("IFNONNULL"); + public static final int IFNULL = valueInt("IFNULL"); + public static final int ILOAD = valueInt("ILOAD"); + public static final int INVOKEINTERFACE = valueInt("INVOKEINTERFACE"); + public static final int INVOKESPECIAL = valueInt("INVOKESPECIAL"); + public static final int INVOKESTATIC = valueInt("INVOKESTATIC"); + public static final int INVOKEVIRTUAL = valueInt("INVOKEVIRTUAL"); + public static final int IRETURN = valueInt("IRETURN"); + public static final int NEW = valueInt("NEW"); + public static final int POP = valueInt("POP"); + public static final int PUTFIELD = valueInt("PUTFIELD"); + public static final int PUTSTATIC = valueInt("PUTSTATIC"); + public static final int RETURN = valueInt("RETURN"); + public static final int SIPUSH = valueInt("SIPUSH"); + public static final int V1_8 = Opcodes.valueInt("V1_8"); + public static final int ACC_BRIDGE = Opcodes.valueInt("ACC_BRIDGE"); + public static final int ISTORE = Opcodes.valueInt("ISTORE"); + public static final int DLOAD = Opcodes.valueInt("DLOAD"); + public static final int LLOAD = Opcodes.valueInt("LLOAD"); + public static final int ASM5 = Opcodes.valueInt("ASM5"); - public static int valueInt(String fieldName) { - return ((int) Util.getFieldValue(ASM_OPCCODES_MAP, fieldName, Integer.TYPE)); - } - public static Integer valueInteger(String fieldName) { - return ((Integer) Util.getFieldValue(ASM_OPCCODES_MAP, fieldName, Integer.class)); + + + private static int valueInt(String fieldName) { + return ((int) Util.getFieldValue(ASM_OPCCODES_MAP, fieldName, Integer.TYPE)); } public static Class getOpcodesClass() { diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/dynamic/DynamicClassWriter.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/dynamic/DynamicClassWriter.java index 5c8f48d3df9..1280924a683 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/dynamic/DynamicClassWriter.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/dynamic/DynamicClassWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -19,24 +19,24 @@ package org.eclipse.persistence.dynamic; //static imports -import static org.eclipse.persistence.internal.dynamic.DynamicPropertiesManager.PROPERTIES_MANAGER_FIELD; -//javase imports -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.List; -//EclipseLink imports -import org.eclipse.persistence.dynamic.DynamicClassLoader.EnumInfo; -import org.eclipse.persistence.exceptions.DynamicException; -import org.eclipse.persistence.internal.dynamic.DynamicEntityImpl; -import org.eclipse.persistence.internal.dynamic.DynamicPropertiesManager; -import org.eclipse.persistence.internal.helper.Helper; import org.eclipse.persistence.asm.ClassWriter; import org.eclipse.persistence.asm.EclipseLinkASMClassWriter; import org.eclipse.persistence.asm.MethodVisitor; import org.eclipse.persistence.asm.Opcodes; import org.eclipse.persistence.asm.Type; +import org.eclipse.persistence.dynamic.DynamicClassLoader.EnumInfo; +import org.eclipse.persistence.exceptions.DynamicException; +import org.eclipse.persistence.internal.dynamic.DynamicEntityImpl; +import org.eclipse.persistence.internal.dynamic.DynamicPropertiesManager; +import org.eclipse.persistence.internal.helper.Helper; + +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.List; + +import static org.eclipse.persistence.internal.dynamic.DynamicPropertiesManager.PROPERTIES_MANAGER_FIELD; /** * Write the byte codes of a dynamic entity class. The class writer will create @@ -160,31 +160,31 @@ public byte[] writeClass(DynamicClassLoader loader, String className) throws Cla ClassWriter cw = new EclipseLinkASMClassWriter(); // public class Foo extends DynamicEntityImpl { - cw.visit(Opcodes.valueInt("ACC_PUBLIC") + Opcodes.valueInt("ACC_SUPER"), classNameAsSlashes, null, parentClassNameAsSlashes, interfaces != null ? interfaces.toArray(new String[interfaces.size()]) : null); + cw.visit(Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, classNameAsSlashes, null, parentClassNameAsSlashes, interfaces != null ? interfaces.toArray(new String[interfaces.size()]) : null); // public static DynamicPropertiesManager DPM = new // DynamicPropertiesManager(); - cw.visitField(Opcodes.valueInt("ACC_PUBLIC") + Opcodes.valueInt("ACC_STATIC"), PROPERTIES_MANAGER_FIELD, "L" + DYNAMIC_PROPERTIES_MANAGER_CLASSNAME_SLASHES + ";", null, null); - MethodVisitor mv = cw.visitMethod(Opcodes.valueInt("ACC_STATIC"), CLINIT, "()V", null, null); - mv.visitTypeInsn(Opcodes.valueInt("NEW"), DYNAMIC_PROPERTIES_MANAGER_CLASSNAME_SLASHES); - mv.visitInsn(Opcodes.valueInt("DUP")); - mv.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), DYNAMIC_PROPERTIES_MANAGER_CLASSNAME_SLASHES, INIT, "()V", false); - mv.visitFieldInsn(Opcodes.valueInt("PUTSTATIC"), classNameAsSlashes, PROPERTIES_MANAGER_FIELD, "L" + DYNAMIC_PROPERTIES_MANAGER_CLASSNAME_SLASHES + ";"); - mv.visitInsn(Opcodes.valueInt("RETURN")); + cw.visitField(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, PROPERTIES_MANAGER_FIELD, "L" + DYNAMIC_PROPERTIES_MANAGER_CLASSNAME_SLASHES + ";", null, null); + MethodVisitor mv = cw.visitMethod(Opcodes.ACC_STATIC, CLINIT, "()V", null, null); + mv.visitTypeInsn(Opcodes.NEW, DYNAMIC_PROPERTIES_MANAGER_CLASSNAME_SLASHES); + mv.visitInsn(Opcodes.DUP); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, DYNAMIC_PROPERTIES_MANAGER_CLASSNAME_SLASHES, INIT, "()V", false); + mv.visitFieldInsn(Opcodes.PUTSTATIC, classNameAsSlashes, PROPERTIES_MANAGER_FIELD, "L" + DYNAMIC_PROPERTIES_MANAGER_CLASSNAME_SLASHES + ";"); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(0, 0); // public Foo() { // super(); // } - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), INIT, "()V", null, null); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), parentClassNameAsSlashes, INIT, "()V", false); - mv.visitInsn(Opcodes.valueInt("RETURN")); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC, INIT, "()V", null, null); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, parentClassNameAsSlashes, INIT, "()V", false); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(0, 0); - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "fetchPropertiesManager", "()L" + DYNAMIC_PROPERTIES_MANAGER_CLASSNAME_SLASHES + ";", null, null); - mv.visitFieldInsn(Opcodes.valueInt("GETSTATIC"), classNameAsSlashes, PROPERTIES_MANAGER_FIELD, "L" + DYNAMIC_PROPERTIES_MANAGER_CLASSNAME_SLASHES + ";"); - mv.visitInsn(Opcodes.valueInt("ARETURN")); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "fetchPropertiesManager", "()L" + DYNAMIC_PROPERTIES_MANAGER_CLASSNAME_SLASHES + ";", null, null); + mv.visitFieldInsn(Opcodes.GETSTATIC, classNameAsSlashes, PROPERTIES_MANAGER_FIELD, "L" + DYNAMIC_PROPERTIES_MANAGER_CLASSNAME_SLASHES + ";"); + mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(0, 0); addFields(cw, parentClassNameAsSlashes); @@ -221,7 +221,7 @@ protected void addFields(ClassWriter cw, String parentClassType) { protected void addMethods(ClassWriter cw, String parentClassType) { } - public static int[] ICONST = new int[] { Opcodes.valueInt("ICONST_0"), Opcodes.valueInt("ICONST_1"), Opcodes.valueInt("ICONST_2"), Opcodes.valueInt("ICONST_3"), Opcodes.valueInt("ICONST_4"), Opcodes.valueInt("ICONST_5") }; + public static int[] ICONST = new int[] { Opcodes.ICONST_0, Opcodes.ICONST_1, Opcodes.ICONST_2, Opcodes.ICONST_3, Opcodes.ICONST_4, Opcodes.ICONST_5 }; protected byte[] createEnum(EnumInfo enumInfo) { @@ -231,88 +231,88 @@ protected byte[] createEnum(EnumInfo enumInfo) { String internalClassName = className.replace('.', '/'); ClassWriter cw = new EclipseLinkASMClassWriter(); - cw.visit(Opcodes.valueInt("ACC_PUBLIC") + Opcodes.valueInt("ACC_FINAL") + Opcodes.valueInt("ACC_SUPER") + Opcodes.valueInt("ACC_ENUM"), internalClassName, null, "java/lang/Enum", null); + cw.visit(Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER + Opcodes.ACC_ENUM, internalClassName, null, "java/lang/Enum", null); // Add the individual enum values for (String enumValue : enumValues) { - cw.visitField(Opcodes.valueInt("ACC_PUBLIC") + Opcodes.valueInt("ACC_FINAL") + Opcodes.valueInt("ACC_STATIC") + Opcodes.valueInt("ACC_ENUM"), enumValue, "L" + internalClassName + ";", null, null); + cw.visitField(Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_STATIC + Opcodes.ACC_ENUM, enumValue, "L" + internalClassName + ";", null, null); } // add the synthetic "$VALUES" field - cw.visitField(Opcodes.valueInt("ACC_PRIVATE") + Opcodes.valueInt("ACC_FINAL") + Opcodes.valueInt("ACC_STATIC") + Opcodes.valueInt("ACC_SYNTHETIC"), "$VALUES", "[L" + internalClassName + ";", null, null); + cw.visitField(Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL + Opcodes.ACC_STATIC + Opcodes.ACC_SYNTHETIC, "$VALUES", "[L" + internalClassName + ";", null, null); // Add the "values()" method - MethodVisitor mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC") + Opcodes.valueInt("ACC_STATIC"), "values", "()[L" + internalClassName + ";", null, null); - mv.visitFieldInsn(Opcodes.valueInt("GETSTATIC"), internalClassName, "$VALUES", "[L" + internalClassName + ";"); - mv.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), "[L" + internalClassName + ";", "clone", "()Ljava/lang/Object;", false); - mv.visitTypeInsn(Opcodes.valueInt("CHECKCAST"), "[L" + internalClassName + ";"); - mv.visitInsn(Opcodes.valueInt("ARETURN")); + MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, "values", "()[L" + internalClassName + ";", null, null); + mv.visitFieldInsn(Opcodes.GETSTATIC, internalClassName, "$VALUES", "[L" + internalClassName + ";"); + mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "[L" + internalClassName + ";", "clone", "()Ljava/lang/Object;", false); + mv.visitTypeInsn(Opcodes.CHECKCAST, "[L" + internalClassName + ";"); + mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(1, 0); // Add the "valueOf()" method - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC") + Opcodes.valueInt("ACC_STATIC"), "valueOf", "(Ljava/lang/String;)L" + internalClassName + ";", null, null); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, "valueOf", "(Ljava/lang/String;)L" + internalClassName + ";", null, null); mv.visitLdcInsn(Type.getType("L" + internalClassName + ";").unwrap()); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitMethodInsn(Opcodes.valueInt("INVOKESTATIC"), "java/lang/Enum", "valueOf", "(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;", false); - mv.visitTypeInsn(Opcodes.valueInt("CHECKCAST"), internalClassName); - mv.visitInsn(Opcodes.valueInt("ARETURN")); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Enum", "valueOf", "(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;", false); + mv.visitTypeInsn(Opcodes.CHECKCAST, internalClassName); + mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(2, 1); // Add constructors // SignatureAttribute methodAttrs1 = new SignatureAttribute("()V"); - mv = cw.visitMethod(Opcodes.valueInt("ACC_PRIVATE"), "", "(Ljava/lang/String;I)V", null, null); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - mv.visitVarInsn(Opcodes.valueInt("ILOAD"), 2); - mv.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), "java/lang/Enum", "", "(Ljava/lang/String;I)V", false); - mv.visitInsn(Opcodes.valueInt("RETURN")); + mv = cw.visitMethod(Opcodes.ACC_PRIVATE, "", "(Ljava/lang/String;I)V", null, null); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitVarInsn(Opcodes.ALOAD, 1); + mv.visitVarInsn(Opcodes.ILOAD, 2); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Enum", "", "(Ljava/lang/String;I)V", false); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(3, 3); // Add enum constants - mv = cw.visitMethod(Opcodes.valueInt("ACC_STATIC"), "", "()V", null, null); + mv = cw.visitMethod(Opcodes.ACC_STATIC, "", "()V", null, null); int lastCount = 0; for (int i = 0; i < enumValues.length; i++) { String enumValue = enumValues[i]; - mv.visitTypeInsn(Opcodes.valueInt("NEW"), internalClassName); - mv.visitInsn(Opcodes.valueInt("DUP")); + mv.visitTypeInsn(Opcodes.NEW, internalClassName); + mv.visitInsn(Opcodes.DUP); mv.visitLdcInsn(enumValue); if (i <= 5) { mv.visitInsn(ICONST[i]); } else if (i <= 127) { - mv.visitIntInsn(Opcodes.valueInt("BIPUSH"), i); + mv.visitIntInsn(Opcodes.BIPUSH, i); } else { - mv.visitIntInsn(Opcodes.valueInt("SIPUSH"), i); + mv.visitIntInsn(Opcodes.SIPUSH, i); } - mv.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), internalClassName, "", "(Ljava/lang/String;I)V", false); - mv.visitFieldInsn(Opcodes.valueInt("PUTSTATIC"), internalClassName, enumValue, "L" + internalClassName + ";"); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, internalClassName, "", "(Ljava/lang/String;I)V", false); + mv.visitFieldInsn(Opcodes.PUTSTATIC, internalClassName, enumValue, "L" + internalClassName + ";"); lastCount = i; } if (lastCount < 5) { mv.visitInsn(ICONST[lastCount + 1]); } else if (lastCount < 127) { - mv.visitIntInsn(Opcodes.valueInt("BIPUSH"), lastCount + 1); + mv.visitIntInsn(Opcodes.BIPUSH, lastCount + 1); } else { - mv.visitIntInsn(Opcodes.valueInt("SIPUSH"), lastCount + 1); + mv.visitIntInsn(Opcodes.SIPUSH, lastCount + 1); } - mv.visitTypeInsn(Opcodes.valueInt("ANEWARRAY"), internalClassName); + mv.visitTypeInsn(Opcodes.ANEWARRAY, internalClassName); for (int i = 0; i < enumValues.length; i++) { String enumValue = enumValues[i]; - mv.visitInsn(Opcodes.valueInt("DUP")); + mv.visitInsn(Opcodes.DUP); if (i <= 5) { mv.visitInsn(ICONST[i]); } else if (i <= 127) { - mv.visitIntInsn(Opcodes.valueInt("BIPUSH"), i); + mv.visitIntInsn(Opcodes.BIPUSH, i); } else { - mv.visitIntInsn(Opcodes.valueInt("SIPUSH"), i); + mv.visitIntInsn(Opcodes.SIPUSH, i); } - mv.visitFieldInsn(Opcodes.valueInt("GETSTATIC"), internalClassName, enumValue, "L" + internalClassName + ";"); - mv.visitInsn(Opcodes.valueInt("AASTORE")); + mv.visitFieldInsn(Opcodes.GETSTATIC, internalClassName, enumValue, "L" + internalClassName + ";"); + mv.visitInsn(Opcodes.AASTORE); } - mv.visitFieldInsn(Opcodes.valueInt("PUTSTATIC"), internalClassName, "$VALUES", "[L" + internalClassName + ";"); - mv.visitInsn(Opcodes.valueInt("RETURN")); + mv.visitFieldInsn(Opcodes.PUTSTATIC, internalClassName, "$VALUES", "[L" + internalClassName + ";"); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(4, 0); cw.visitEnd(); diff --git a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metadata/MetadataDynamicClassWriter.java b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metadata/MetadataDynamicClassWriter.java index 76acfddf7db..1a979a77f93 100644 --- a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metadata/MetadataDynamicClassWriter.java +++ b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metadata/MetadataDynamicClassWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -64,25 +64,25 @@ protected void addMethods(ClassWriter cw, String parentClassType) { Type returnType = getAsmType(accessor); // Add getter - MethodVisitor mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), GET + propertyName, "()" + returnType.getDescriptor(), null, new String[] { DYNAMIC_EXCEPTION }); + MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, GET + propertyName, "()" + returnType.getDescriptor(), null, new String[] { DYNAMIC_EXCEPTION }); mv.visitCode(); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); + mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitLdcInsn(accessor.getAttributeName()); - mv.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), parentClassType, "get", "(" + LJAVA_LANG_STRING + ")" + LJAVA_LANG_OBJECT, false); - mv.visitTypeInsn(Opcodes.valueInt("CHECKCAST"), returnType.getInternalName()); - mv.visitInsn(Opcodes.valueInt("ARETURN")); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, parentClassType, "get", "(" + LJAVA_LANG_STRING + ")" + LJAVA_LANG_OBJECT, false); + mv.visitTypeInsn(Opcodes.CHECKCAST, returnType.getInternalName()); + mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(2, 1); mv.visitEnd(); // Add setter - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), SET + propertyName, "(" + returnType.getDescriptor() + ")V", null, new String[] { DYNAMIC_EXCEPTION }); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC, SET + propertyName, "(" + returnType.getDescriptor() + ")V", null, new String[] { DYNAMIC_EXCEPTION }); mv.visitCode(); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); + mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitLdcInsn("id"); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - mv.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), parentClassType, SET, "(" + LJAVA_LANG_STRING + LJAVA_LANG_OBJECT + ")" + LDYNAMIC_ENTITY, false); - mv.visitInsn(Opcodes.valueInt("POP")); - mv.visitInsn(Opcodes.valueInt("RETURN")); + mv.visitVarInsn(Opcodes.ALOAD, 1); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, parentClassType, SET, "(" + LJAVA_LANG_STRING + LJAVA_LANG_OBJECT + ")" + LDYNAMIC_ENTITY, false); + mv.visitInsn(Opcodes.POP); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(3, 2); mv.visitEnd(); } diff --git a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metadata/accessors/objects/MetadataAsmFactory.java b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metadata/accessors/objects/MetadataAsmFactory.java index 78c92597d26..77a661c2c94 100644 --- a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metadata/accessors/objects/MetadataAsmFactory.java +++ b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metadata/accessors/objects/MetadataAsmFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2018 Hans Harz, Andrew Rustleund, IBM Corporation. All rights reserved. * * This program and the accompanying materials are made available under the @@ -27,25 +27,7 @@ // - 480787 : Wrap several privileged method calls with a doPrivileged block package org.eclipse.persistence.internal.jpa.metadata.accessors.objects; -import java.io.IOException; -import java.io.InputStream; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.persistence.asm.ASMFactory; -import org.eclipse.persistence.asm.AnnotationVisitor; -import org.eclipse.persistence.asm.EclipseLinkAnnotationVisitor; -import org.eclipse.persistence.asm.Attribute; -import org.eclipse.persistence.asm.ClassReader; -import org.eclipse.persistence.asm.EclipseLinkClassVisitor; -import org.eclipse.persistence.asm.EclipseLinkFieldVisitor; -import org.eclipse.persistence.asm.EclipseLinkClassReader; -import org.eclipse.persistence.asm.FieldVisitor; -import org.eclipse.persistence.asm.EclipseLinkMethodVisitor; -import org.eclipse.persistence.asm.MethodVisitor; -import org.eclipse.persistence.asm.Type; +import org.eclipse.persistence.asm.*; import org.eclipse.persistence.internal.helper.Helper; import org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor; import org.eclipse.persistence.internal.jpa.metadata.MetadataLogger; @@ -55,6 +37,13 @@ import org.eclipse.persistence.logging.SessionLog; import org.eclipse.persistence.logging.SessionLogEntry; +import java.io.IOException; +import java.io.InputStream; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.ArrayList; +import java.util.List; + /** * INTERNAL: A metadata factory that uses ASM technology and no reflection * whatsoever to process the metadata model. @@ -101,7 +90,7 @@ protected void buildClassMetadata(MetadataClass metadataClass, String className, ClassReader reader = ASMFactory.createClassReader(stream); Attribute[] attributes = new Attribute[0]; - reader.accept(visitor, attributes, ClassReader.valueInt("SKIP_CODE") | ClassReader.valueInt("SKIP_DEBUG") | ClassReader.valueInt("SKIP_FRAMES")); + reader.accept(visitor, attributes, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES); } catch (IllegalArgumentException iae) { // class was probably compiled with some newer than officially // supported and tested JDK @@ -132,7 +121,7 @@ protected void buildClassMetadata(MetadataClass metadataClass, String className, //as checkClassVersion is not visible by public constructor ClassReader reader = ASMFactory.createClassReader(stream, false); Attribute[] attributes = new Attribute[0]; - reader.accept(visitor, attributes, ClassReader.valueInt("SKIP_CODE") | ClassReader.valueInt("SKIP_DEBUG") | ClassReader.valueInt("SKIP_FRAMES")); + reader.accept(visitor, attributes, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES); } catch (Exception e) { SessionLog log = getLogger().getSession() != null ? getLogger().getSession().getSessionLog() : AbstractSessionLog.getLog(); diff --git a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metadata/accessors/objects/MetadataClass.java b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metadata/accessors/objects/MetadataClass.java index 359e7f4eda6..3906b3b0ef1 100644 --- a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metadata/accessors/objects/MetadataClass.java +++ b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/metadata/accessors/objects/MetadataClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -28,19 +28,12 @@ // - 527415: Fix code when locale is tr, az or lt package org.eclipse.persistence.internal.jpa.metadata.accessors.objects; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Set; - import org.eclipse.persistence.asm.Opcodes; import org.eclipse.persistence.internal.helper.Helper; +import java.io.Serializable; +import java.util.*; + /** * INTERNAL: * An object to hold onto a valid JPA decorated class. @@ -478,7 +471,7 @@ public boolean isEnum() { * Return if this is an interface (super is null). */ public boolean isInterface() { - return (Opcodes.valueInt("ACC_INTERFACE") & m_modifiers) != 0; + return (Opcodes.ACC_INTERFACE & m_modifiers) != 0; } /** diff --git a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/weaving/ClassWeaver.java b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/weaving/ClassWeaver.java index ad2adb23699..74844da2c6e 100644 --- a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/weaving/ClassWeaver.java +++ b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/weaving/ClassWeaver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -21,7 +21,6 @@ // - 429992: JavaSE 8/ASM 5.0.1 support (EclipseLink silently ignores Entity classes with lambda expressions) package org.eclipse.persistence.internal.jpa.weaving; -import java.util.Iterator; import org.eclipse.persistence.asm.ASMFactory; import org.eclipse.persistence.asm.AnnotationVisitor; @@ -33,6 +32,8 @@ import org.eclipse.persistence.asm.Type; import org.eclipse.persistence.internal.helper.Helper; +import java.util.Iterator; + /** * INTERNAL: Weaves classes to allow them to support EclipseLink indirection. * Classes are weaved to add a variable of type ValueHolderInterface for each @@ -161,28 +162,28 @@ public static void unwrapPrimitive(AttributeDetails attribute, MethodVisitor vis String wrapper = wrapperFor(attribute.getReferenceClassType().getSort()); int sort = attribute.getReferenceClassType().getSort(); if (sort == Type.BOOLEAN) { - visitor.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), wrapper, "booleanValue", "()Z", false); + visitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, wrapper, "booleanValue", "()Z", false); return; } else if (sort == Type.BYTE) { - visitor.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), wrapper, "byteValue", "()B", false); + visitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, wrapper, "byteValue", "()B", false); return; } else if (sort == Type.CHAR) { - visitor.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), wrapper, "charValue", "()C", false); + visitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, wrapper, "charValue", "()C", false); return; } else if (sort == Type.SHORT) { - visitor.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), wrapper, "shortValue", "()S", false); + visitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, wrapper, "shortValue", "()S", false); return; } else if (sort == Type.INT) { - visitor.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), wrapper, "intValue", "()I", false); + visitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, wrapper, "intValue", "()I", false); return; } else if (sort == Type.FLOAT) { - visitor.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), wrapper, "floatValue", "()F", false); + visitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, wrapper, "floatValue", "()F", false); return; } else if (sort == Type.LONG) { - visitor.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), wrapper, "longValue", "()J", false); + visitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, wrapper, "longValue", "()J", false); return; } else if (sort == Type.DOUBLE) { - visitor.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), wrapper, "doubleValue", "()D", false); + visitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, wrapper, "doubleValue", "()D", false); return; } } @@ -233,7 +234,7 @@ public ClassWeaver(ClassVisitor classWriter, ClassDetails classDetails) { */ public void addValueHolder(AttributeDetails attributeDetails) { String attribute = attributeDetails.getAttributeName(); - FieldVisitor fv = cv.visitField(Opcodes.valueInt("ACC_PROTECTED"), PERSISTENCE_FIELDNAME_PREFIX + attribute + PERSISTENCE_FIELDNAME_POSTFIX, VHI_SIGNATURE, null, null); + FieldVisitor fv = cv.visitField(Opcodes.ACC_PROTECTED, PERSISTENCE_FIELDNAME_PREFIX + attribute + PERSISTENCE_FIELDNAME_POSTFIX, VHI_SIGNATURE, null, null); // only mark @Transient if this is property access. Otherwise, the // @Transient annotation could mistakenly @@ -255,7 +256,7 @@ public void addValueHolder(AttributeDetails attributeDetails) { * private transient _persistence_listener; */ public void addPropertyChangeListener(boolean attributeAccess) { - cv.visitField(Opcodes.valueInt("ACC_PROTECTED") + Opcodes.valueInt("ACC_TRANSIENT"), "_persistence_listener", PCL_SIGNATURE, null, null); + cv.visitField(Opcodes.ACC_PROTECTED + Opcodes.ACC_TRANSIENT, "_persistence_listener", PCL_SIGNATURE, null, null); } /** @@ -266,10 +267,10 @@ public void addPropertyChangeListener(boolean attributeAccess) { * return _persistence_listener; } */ public void addGetPropertyChangeListener(ClassDetails classDetails) { - MethodVisitor cv_getPCL = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "_persistence_getPropertyChangeListener", "()" + PCL_SIGNATURE, null, null); - cv_getPCL.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_getPCL.visitFieldInsn(Opcodes.valueInt("GETFIELD"), classDetails.getClassName(), "_persistence_listener", PCL_SIGNATURE); - cv_getPCL.visitInsn(Opcodes.valueInt("ARETURN")); + MethodVisitor cv_getPCL = cv.visitMethod(Opcodes.ACC_PUBLIC, "_persistence_getPropertyChangeListener", "()" + PCL_SIGNATURE, null, null); + cv_getPCL.visitVarInsn(Opcodes.ALOAD, 0); + cv_getPCL.visitFieldInsn(Opcodes.GETFIELD, classDetails.getClassName(), "_persistence_listener", PCL_SIGNATURE); + cv_getPCL.visitInsn(Opcodes.ARETURN); cv_getPCL.visitMaxs(0, 0); } @@ -282,11 +283,11 @@ public void addGetPropertyChangeListener(ClassDetails classDetails) { * } */ public void addSetPropertyChangeListener(ClassDetails classDetails) { - MethodVisitor cv_setPCL = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "_persistence_setPropertyChangeListener", "(" + PCL_SIGNATURE + ")V", null, null); - cv_setPCL.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_setPCL.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - cv_setPCL.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), classDetails.getClassName(), "_persistence_listener", PCL_SIGNATURE); - cv_setPCL.visitInsn(Opcodes.valueInt("RETURN")); + MethodVisitor cv_setPCL = cv.visitMethod(Opcodes.ACC_PUBLIC, "_persistence_setPropertyChangeListener", "(" + PCL_SIGNATURE + ")V", null, null); + cv_setPCL.visitVarInsn(Opcodes.ALOAD, 0); + cv_setPCL.visitVarInsn(Opcodes.ALOAD, 1); + cv_setPCL.visitFieldInsn(Opcodes.PUTFIELD, classDetails.getClassName(), "_persistence_listener", PCL_SIGNATURE); + cv_setPCL.visitInsn(Opcodes.RETURN); cv_setPCL.visitMaxs(0, 0); } @@ -300,37 +301,37 @@ public void addSetPropertyChangeListener(ClassDetails classDetails) { */ public void addPropertyChange(ClassDetails classDetails) { // create the _toplink_propertyChange() method - MethodVisitor cv_addPC = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "_persistence_propertyChange", "(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V", null, null); + MethodVisitor cv_addPC = cv.visitMethod(Opcodes.ACC_PUBLIC, "_persistence_propertyChange", "(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V", null, null); // if (_toplink_Listener != null) - cv_addPC.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_addPC.visitFieldInsn(Opcodes.valueInt("GETFIELD"), classDetails.getClassName(), "_persistence_listener", PCL_SIGNATURE); + cv_addPC.visitVarInsn(Opcodes.ALOAD, 0); + cv_addPC.visitFieldInsn(Opcodes.GETFIELD, classDetails.getClassName(), "_persistence_listener", PCL_SIGNATURE); Label l0 = ASMFactory.createLabel(); - cv_addPC.visitJumpInsn(Opcodes.valueInt("IFNULL"), l0); + cv_addPC.visitJumpInsn(Opcodes.IFNULL, l0); // if (obj != obj1) - cv_addPC.visitVarInsn(Opcodes.valueInt("ALOAD"), 2); - cv_addPC.visitVarInsn(Opcodes.valueInt("ALOAD"), 3); - cv_addPC.visitJumpInsn(Opcodes.valueInt("IF_ACMPEQ"), l0); + cv_addPC.visitVarInsn(Opcodes.ALOAD, 2); + cv_addPC.visitVarInsn(Opcodes.ALOAD, 3); + cv_addPC.visitJumpInsn(Opcodes.IF_ACMPEQ, l0); // _toplink_listener.propertyChange(...); - cv_addPC.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_addPC.visitFieldInsn(Opcodes.valueInt("GETFIELD"), classDetails.getClassName(), "_persistence_listener", PCL_SIGNATURE); - cv_addPC.visitTypeInsn(Opcodes.valueInt("NEW"), PCE_SHORT_SIGNATURE); - cv_addPC.visitInsn(Opcodes.valueInt("DUP")); + cv_addPC.visitVarInsn(Opcodes.ALOAD, 0); + cv_addPC.visitFieldInsn(Opcodes.GETFIELD, classDetails.getClassName(), "_persistence_listener", PCL_SIGNATURE); + cv_addPC.visitTypeInsn(Opcodes.NEW, PCE_SHORT_SIGNATURE); + cv_addPC.visitInsn(Opcodes.DUP); // new PropertyChangeEvent(this, s, obj, obj1) - cv_addPC.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_addPC.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - cv_addPC.visitVarInsn(Opcodes.valueInt("ALOAD"), 2); - cv_addPC.visitVarInsn(Opcodes.valueInt("ALOAD"), 3); - cv_addPC.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), PCE_SHORT_SIGNATURE, "", "(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V", false); - cv_addPC.visitMethodInsn(Opcodes.valueInt("INVOKEINTERFACE"), PCL_SHORT_SIGNATURE, "propertyChange", "(" + PCE_SIGNATURE + ")V", true); + cv_addPC.visitVarInsn(Opcodes.ALOAD, 0); + cv_addPC.visitVarInsn(Opcodes.ALOAD, 1); + cv_addPC.visitVarInsn(Opcodes.ALOAD, 2); + cv_addPC.visitVarInsn(Opcodes.ALOAD, 3); + cv_addPC.visitMethodInsn(Opcodes.INVOKESPECIAL, PCE_SHORT_SIGNATURE, "", "(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V", false); + cv_addPC.visitMethodInsn(Opcodes.INVOKEINTERFACE, PCL_SHORT_SIGNATURE, "propertyChange", "(" + PCE_SIGNATURE + ")V", true); // } cv_addPC.visitLabel(l0); - cv_addPC.visitInsn(Opcodes.valueInt("RETURN")); + cv_addPC.visitInsn(Opcodes.RETURN); cv_addPC.visitMaxs(0, 0); } @@ -350,37 +351,37 @@ public void addInitializerForValueHolder(ClassDetails classDetails, AttributeDet // Create a getter method for the new valueholder // protected void _persistence_initialize_attribute_vh(){ - MethodVisitor cv_init_VH = cv.visitMethod(Opcodes.valueInt("ACC_PROTECTED"), "_persistence_initialize_" + attribute + PERSISTENCE_FIELDNAME_POSTFIX, "()V", null, null); + MethodVisitor cv_init_VH = cv.visitMethod(Opcodes.ACC_PROTECTED, "_persistence_initialize_" + attribute + PERSISTENCE_FIELDNAME_POSTFIX, "()V", null, null); // if(_persistence_attribute_vh == null){ - cv_init_VH.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_init_VH.visitFieldInsn(Opcodes.valueInt("GETFIELD"), className, PERSISTENCE_FIELDNAME_PREFIX + attribute + PERSISTENCE_FIELDNAME_POSTFIX, VHI_SIGNATURE); + cv_init_VH.visitVarInsn(Opcodes.ALOAD, 0); + cv_init_VH.visitFieldInsn(Opcodes.GETFIELD, className, PERSISTENCE_FIELDNAME_PREFIX + attribute + PERSISTENCE_FIELDNAME_POSTFIX, VHI_SIGNATURE); Label l0 = ASMFactory.createLabel(); - cv_init_VH.visitJumpInsn(Opcodes.valueInt("IFNONNULL"), l0); + cv_init_VH.visitJumpInsn(Opcodes.IFNONNULL, l0); // _persistence_attribute_vh = new ValueHolder(this.attribute); - cv_init_VH.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_init_VH.visitTypeInsn(Opcodes.valueInt("NEW"), VH_SHORT_SIGNATURE); - cv_init_VH.visitInsn(Opcodes.valueInt("DUP")); + cv_init_VH.visitVarInsn(Opcodes.ALOAD, 0); + cv_init_VH.visitTypeInsn(Opcodes.NEW, VH_SHORT_SIGNATURE); + cv_init_VH.visitInsn(Opcodes.DUP); if (attributeDetails.hasField()) { - cv_init_VH.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_init_VH.visitFieldInsn(Opcodes.valueInt("GETFIELD"), className, attribute, attributeDetails.getReferenceClassType().getDescriptor()); - cv_init_VH.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), VH_SHORT_SIGNATURE, "", "(Ljava/lang/Object;)V", false); + cv_init_VH.visitVarInsn(Opcodes.ALOAD, 0); + cv_init_VH.visitFieldInsn(Opcodes.GETFIELD, className, attribute, attributeDetails.getReferenceClassType().getDescriptor()); + cv_init_VH.visitMethodInsn(Opcodes.INVOKESPECIAL, VH_SHORT_SIGNATURE, "", "(Ljava/lang/Object;)V", false); } else { - cv_init_VH.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), VH_SHORT_SIGNATURE, "", "()V", false); + cv_init_VH.visitMethodInsn(Opcodes.INVOKESPECIAL, VH_SHORT_SIGNATURE, "", "()V", false); } - cv_init_VH.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), className, PERSISTENCE_FIELDNAME_PREFIX + attribute + PERSISTENCE_FIELDNAME_POSTFIX, VHI_SIGNATURE); + cv_init_VH.visitFieldInsn(Opcodes.PUTFIELD, className, PERSISTENCE_FIELDNAME_PREFIX + attribute + PERSISTENCE_FIELDNAME_POSTFIX, VHI_SIGNATURE); // _persistence_attribute_vh.setIsNewlyWeavedValueHolder(true); - cv_init_VH.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_init_VH.visitFieldInsn(Opcodes.valueInt("GETFIELD"), className, PERSISTENCE_FIELDNAME_PREFIX + attribute + PERSISTENCE_FIELDNAME_POSTFIX, VHI_SIGNATURE); - cv_init_VH.visitInsn(Opcodes.valueInt("ICONST_1")); - cv_init_VH.visitMethodInsn(Opcodes.valueInt("INVOKEINTERFACE"), VHI_SHORT_SIGNATURE, "setIsNewlyWeavedValueHolder", "(Z)V", true); + cv_init_VH.visitVarInsn(Opcodes.ALOAD, 0); + cv_init_VH.visitFieldInsn(Opcodes.GETFIELD, className, PERSISTENCE_FIELDNAME_PREFIX + attribute + PERSISTENCE_FIELDNAME_POSTFIX, VHI_SIGNATURE); + cv_init_VH.visitInsn(Opcodes.ICONST_1); + cv_init_VH.visitMethodInsn(Opcodes.INVOKEINTERFACE, VHI_SHORT_SIGNATURE, "setIsNewlyWeavedValueHolder", "(Z)V", true); // } cv_init_VH.visitLabel(l0); - cv_init_VH.visitInsn(Opcodes.valueInt("RETURN")); + cv_init_VH.visitInsn(Opcodes.RETURN); cv_init_VH.visitMaxs(0, 0); } @@ -399,59 +400,59 @@ public void addGetterMethodForValueHolder(ClassDetails classDetails, AttributeDe String attribute = attributeDetails.getAttributeName(); String className = classDetails.getClassName(); // Create a getter method for the new valueholder - MethodVisitor cv_get_VH = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), PERSISTENCE_GET + attribute + PERSISTENCE_FIELDNAME_POSTFIX, "()" + VHI_SIGNATURE, null, null); + MethodVisitor cv_get_VH = cv.visitMethod(Opcodes.ACC_PUBLIC, PERSISTENCE_GET + attribute + PERSISTENCE_FIELDNAME_POSTFIX, "()" + VHI_SIGNATURE, null, null); // _persistence_initialize_attributeName_vh(); - cv_get_VH.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_get_VH.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), classDetails.getClassName(), "_persistence_initialize_" + attributeDetails.getAttributeName() + PERSISTENCE_FIELDNAME_POSTFIX, "()V", false); + cv_get_VH.visitVarInsn(Opcodes.ALOAD, 0); + cv_get_VH.visitMethodInsn(Opcodes.INVOKEVIRTUAL, classDetails.getClassName(), "_persistence_initialize_" + attributeDetails.getAttributeName() + PERSISTENCE_FIELDNAME_POSTFIX, "()V", false); // if (_toplink_foo_vh.isCoordinatedWithProperty() || // _toplink_foo_vh.isNewlyWeavedValueHolder()){ - cv_get_VH.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_get_VH.visitFieldInsn(Opcodes.valueInt("GETFIELD"), classDetails.getClassName(), PERSISTENCE_FIELDNAME_PREFIX + attribute + PERSISTENCE_FIELDNAME_POSTFIX, VHI_SIGNATURE); - cv_get_VH.visitMethodInsn(Opcodes.valueInt("INVOKEINTERFACE"), VHI_SHORT_SIGNATURE, "isCoordinatedWithProperty", "()Z", true); + cv_get_VH.visitVarInsn(Opcodes.ALOAD, 0); + cv_get_VH.visitFieldInsn(Opcodes.GETFIELD, classDetails.getClassName(), PERSISTENCE_FIELDNAME_PREFIX + attribute + PERSISTENCE_FIELDNAME_POSTFIX, VHI_SIGNATURE); + cv_get_VH.visitMethodInsn(Opcodes.INVOKEINTERFACE, VHI_SHORT_SIGNATURE, "isCoordinatedWithProperty", "()Z", true); Label l0 = ASMFactory.createLabel(); - cv_get_VH.visitJumpInsn(Opcodes.valueInt("IFNE"), l0); - cv_get_VH.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_get_VH.visitFieldInsn(Opcodes.valueInt("GETFIELD"), classDetails.getClassName(), PERSISTENCE_FIELDNAME_PREFIX + attribute + PERSISTENCE_FIELDNAME_POSTFIX, VHI_SIGNATURE); - cv_get_VH.visitMethodInsn(Opcodes.valueInt("INVOKEINTERFACE"), VHI_SHORT_SIGNATURE, "isNewlyWeavedValueHolder", "()Z", true); + cv_get_VH.visitJumpInsn(Opcodes.IFNE, l0); + cv_get_VH.visitVarInsn(Opcodes.ALOAD, 0); + cv_get_VH.visitFieldInsn(Opcodes.GETFIELD, classDetails.getClassName(), PERSISTENCE_FIELDNAME_PREFIX + attribute + PERSISTENCE_FIELDNAME_POSTFIX, VHI_SIGNATURE); + cv_get_VH.visitMethodInsn(Opcodes.INVOKEINTERFACE, VHI_SHORT_SIGNATURE, "isNewlyWeavedValueHolder", "()Z", true); Label l1 = ASMFactory.createLabel(); - cv_get_VH.visitJumpInsn(Opcodes.valueInt("IFEQ"), l1); + cv_get_VH.visitJumpInsn(Opcodes.IFEQ, l1); cv_get_VH.visitLabel(l0); - cv_get_VH.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); + cv_get_VH.visitVarInsn(Opcodes.ALOAD, 0); // EntityC object = (EntityC)getFoo(); if (attributeDetails.getGetterMethodName() != null) { - cv_get_VH.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), classDetails.getClassName(), attributeDetails.getGetterMethodName(), "()L" + attributeDetails.getReferenceClassName().replace('.', '/') + ";", false); - cv_get_VH.visitTypeInsn(Opcodes.valueInt("CHECKCAST"), attributeDetails.getReferenceClassName().replace('.', '/')); + cv_get_VH.visitMethodInsn(Opcodes.INVOKEVIRTUAL, classDetails.getClassName(), attributeDetails.getGetterMethodName(), "()L" + attributeDetails.getReferenceClassName().replace('.', '/') + ";", false); + cv_get_VH.visitTypeInsn(Opcodes.CHECKCAST, attributeDetails.getReferenceClassName().replace('.', '/')); } else { - cv_get_VH.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), classDetails.getClassName(), PERSISTENCE_GET + attributeDetails.attributeName, "()L" + attributeDetails.getReferenceClassName().replace('.', '/') + ";", false); + cv_get_VH.visitMethodInsn(Opcodes.INVOKEVIRTUAL, classDetails.getClassName(), PERSISTENCE_GET + attributeDetails.attributeName, "()L" + attributeDetails.getReferenceClassName().replace('.', '/') + ";", false); } - cv_get_VH.visitVarInsn(Opcodes.valueInt("ASTORE"), 1); + cv_get_VH.visitVarInsn(Opcodes.ASTORE, 1); // if (object != _toplink_foo_vh.getValue()){ - cv_get_VH.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - cv_get_VH.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_get_VH.visitFieldInsn(Opcodes.valueInt("GETFIELD"), classDetails.getClassName(), PERSISTENCE_FIELDNAME_PREFIX + attribute + PERSISTENCE_FIELDNAME_POSTFIX, VHI_SIGNATURE); - cv_get_VH.visitMethodInsn(Opcodes.valueInt("INVOKEINTERFACE"), VHI_SHORT_SIGNATURE, "getValue", "()Ljava/lang/Object;", true); - cv_get_VH.visitJumpInsn(Opcodes.valueInt("IF_ACMPEQ"), l1); + cv_get_VH.visitVarInsn(Opcodes.ALOAD, 1); + cv_get_VH.visitVarInsn(Opcodes.ALOAD, 0); + cv_get_VH.visitFieldInsn(Opcodes.GETFIELD, classDetails.getClassName(), PERSISTENCE_FIELDNAME_PREFIX + attribute + PERSISTENCE_FIELDNAME_POSTFIX, VHI_SIGNATURE); + cv_get_VH.visitMethodInsn(Opcodes.INVOKEINTERFACE, VHI_SHORT_SIGNATURE, "getValue", "()Ljava/lang/Object;", true); + cv_get_VH.visitJumpInsn(Opcodes.IF_ACMPEQ, l1); // setFoo(object); - cv_get_VH.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_get_VH.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); + cv_get_VH.visitVarInsn(Opcodes.ALOAD, 0); + cv_get_VH.visitVarInsn(Opcodes.ALOAD, 1); if (attributeDetails.getSetterMethodName() != null) { - cv_get_VH.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), classDetails.getClassName(), attributeDetails.getSetterMethodName(), "(L" + attributeDetails.getReferenceClassName().replace('.', '/') + ";)V", false); + cv_get_VH.visitMethodInsn(Opcodes.INVOKEVIRTUAL, classDetails.getClassName(), attributeDetails.getSetterMethodName(), "(L" + attributeDetails.getReferenceClassName().replace('.', '/') + ";)V", false); } else { - cv_get_VH.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), classDetails.getClassName(), PERSISTENCE_SET + attributeDetails.getAttributeName(), "(L" + attributeDetails.getReferenceClassName().replace('.', '/') + ";)V", false); + cv_get_VH.visitMethodInsn(Opcodes.INVOKEVIRTUAL, classDetails.getClassName(), PERSISTENCE_SET + attributeDetails.getAttributeName(), "(L" + attributeDetails.getReferenceClassName().replace('.', '/') + ";)V", false); } // } cv_get_VH.visitLabel(l1); // return _toplink_foo_vh; - cv_get_VH.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_get_VH.visitFieldInsn(Opcodes.valueInt("GETFIELD"), className, PERSISTENCE_FIELDNAME_PREFIX + attribute + PERSISTENCE_FIELDNAME_POSTFIX, VHI_SIGNATURE); - cv_get_VH.visitInsn(Opcodes.valueInt("ARETURN")); + cv_get_VH.visitVarInsn(Opcodes.ALOAD, 0); + cv_get_VH.visitFieldInsn(Opcodes.GETFIELD, className, PERSISTENCE_FIELDNAME_PREFIX + attribute + PERSISTENCE_FIELDNAME_POSTFIX, VHI_SIGNATURE); + cv_get_VH.visitInsn(Opcodes.ARETURN); cv_get_VH.visitMaxs(0, 0); } @@ -470,72 +471,72 @@ public void addSetterMethodForValueHolder(ClassDetails classDetails, AttributeDe String attribute = attributeDetails.getAttributeName(); String className = classDetails.getClassName(); // create a setter method for the new valueholder - MethodVisitor cv_set_value = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), PERSISTENCE_SET + attribute + PERSISTENCE_FIELDNAME_POSTFIX, "(" + VHI_SIGNATURE + ")V", null, null); + MethodVisitor cv_set_value = cv.visitMethod(Opcodes.ACC_PUBLIC, PERSISTENCE_SET + attribute + PERSISTENCE_FIELDNAME_POSTFIX, "(" + VHI_SIGNATURE + ")V", null, null); // _toplink_foo_vh = valueholderinterface; - cv_set_value.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_set_value.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - cv_set_value.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), className, PERSISTENCE_FIELDNAME_PREFIX + attribute + PERSISTENCE_FIELDNAME_POSTFIX, VHI_SIGNATURE); + cv_set_value.visitVarInsn(Opcodes.ALOAD, 0); + cv_set_value.visitVarInsn(Opcodes.ALOAD, 1); + cv_set_value.visitFieldInsn(Opcodes.PUTFIELD, className, PERSISTENCE_FIELDNAME_PREFIX + attribute + PERSISTENCE_FIELDNAME_POSTFIX, VHI_SIGNATURE); // if (valueholderinterface.isInstantiated()){ - cv_set_value.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - cv_set_value.visitMethodInsn(Opcodes.valueInt("INVOKEINTERFACE"), VHI_SHORT_SIGNATURE, "isInstantiated", "()Z", true); + cv_set_value.visitVarInsn(Opcodes.ALOAD, 1); + cv_set_value.visitMethodInsn(Opcodes.INVOKEINTERFACE, VHI_SHORT_SIGNATURE, "isInstantiated", "()Z", true); Label l0 = ASMFactory.createLabel(); - cv_set_value.visitJumpInsn(Opcodes.valueInt("IFEQ"), l0); + cv_set_value.visitJumpInsn(Opcodes.IFEQ, l0); // Object object = getFoo(); - cv_set_value.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); + cv_set_value.visitVarInsn(Opcodes.ALOAD, 0); if (attributeDetails.getGetterMethodName() != null) { - cv_set_value.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), className, attributeDetails.getGetterMethodName(), "()L" + attributeDetails.getReferenceClassName().replace('.', '/') + ";", false); + cv_set_value.visitMethodInsn(Opcodes.INVOKEVIRTUAL, className, attributeDetails.getGetterMethodName(), "()L" + attributeDetails.getReferenceClassName().replace('.', '/') + ";", false); } else { - cv_set_value.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), className, PERSISTENCE_GET + attributeDetails.attributeName, "()L" + attributeDetails.getReferenceClassName().replace('.', '/') + ";", false); + cv_set_value.visitMethodInsn(Opcodes.INVOKEVIRTUAL, className, PERSISTENCE_GET + attributeDetails.attributeName, "()L" + attributeDetails.getReferenceClassName().replace('.', '/') + ";", false); } - cv_set_value.visitVarInsn(Opcodes.valueInt("ASTORE"), 2); + cv_set_value.visitVarInsn(Opcodes.ASTORE, 2); // Object value = valueholderinterface.getValue(); - cv_set_value.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - cv_set_value.visitMethodInsn(Opcodes.valueInt("INVOKEINTERFACE"), VHI_SHORT_SIGNATURE, "getValue", "()Ljava/lang/Object;", true); - cv_set_value.visitVarInsn(Opcodes.valueInt("ASTORE"), 3); + cv_set_value.visitVarInsn(Opcodes.ALOAD, 1); + cv_set_value.visitMethodInsn(Opcodes.INVOKEINTERFACE, VHI_SHORT_SIGNATURE, "getValue", "()Ljava/lang/Object;", true); + cv_set_value.visitVarInsn(Opcodes.ASTORE, 3); // if (object != value){ - cv_set_value.visitVarInsn(Opcodes.valueInt("ALOAD"), 2); - cv_set_value.visitVarInsn(Opcodes.valueInt("ALOAD"), 3); + cv_set_value.visitVarInsn(Opcodes.ALOAD, 2); + cv_set_value.visitVarInsn(Opcodes.ALOAD, 3); if (attributeDetails.getSetterMethodName() != null) { - cv_set_value.visitJumpInsn(Opcodes.valueInt("IF_ACMPEQ"), l0); + cv_set_value.visitJumpInsn(Opcodes.IF_ACMPEQ, l0); // setFoo((EntityC)value); - cv_set_value.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_set_value.visitVarInsn(Opcodes.valueInt("ALOAD"), 3); - cv_set_value.visitTypeInsn(Opcodes.valueInt("CHECKCAST"), attributeDetails.getReferenceClassName().replace('.', '/')); - cv_set_value.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), className, attributeDetails.getSetterMethodName(), "(L" + attributeDetails.getReferenceClassName().replace('.', '/') + ";)V", false); + cv_set_value.visitVarInsn(Opcodes.ALOAD, 0); + cv_set_value.visitVarInsn(Opcodes.ALOAD, 3); + cv_set_value.visitTypeInsn(Opcodes.CHECKCAST, attributeDetails.getReferenceClassName().replace('.', '/')); + cv_set_value.visitMethodInsn(Opcodes.INVOKEVIRTUAL, className, attributeDetails.getSetterMethodName(), "(L" + attributeDetails.getReferenceClassName().replace('.', '/') + ";)V", false); //} cv_set_value.visitLabel(l0); } else { Label l1 = ASMFactory.createLabel(); - cv_set_value.visitJumpInsn(Opcodes.valueInt("IF_ACMPEQ"), l1); + cv_set_value.visitJumpInsn(Opcodes.IF_ACMPEQ, l1); // _persistence_setFoo((EntityC)value); - cv_set_value.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_set_value.visitVarInsn(Opcodes.valueInt("ALOAD"), 3); - cv_set_value.visitTypeInsn(Opcodes.valueInt("CHECKCAST"), attributeDetails.getReferenceClassName().replace('.', '/')); - cv_set_value.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), className, PERSISTENCE_SET + attributeDetails.getAttributeName(), "(L" + attributeDetails.getReferenceClassName().replace('.', '/') + ";)V", false); + cv_set_value.visitVarInsn(Opcodes.ALOAD, 0); + cv_set_value.visitVarInsn(Opcodes.ALOAD, 3); + cv_set_value.visitTypeInsn(Opcodes.CHECKCAST, attributeDetails.getReferenceClassName().replace('.', '/')); + cv_set_value.visitMethodInsn(Opcodes.INVOKEVIRTUAL, className, PERSISTENCE_SET + attributeDetails.getAttributeName(), "(L" + attributeDetails.getReferenceClassName().replace('.', '/') + ";)V", false); // } cv_set_value.visitLabel(l1); - cv_set_value.visitFrame(Opcodes.valueInt("F_SAME"), 0, null, 0, null); + cv_set_value.visitFrame(Opcodes.F_SAME, 0, null, 0, null); Label l2 = ASMFactory.createLabel(); - cv_set_value.visitJumpInsn(Opcodes.valueInt("GOTO"), l2); + cv_set_value.visitJumpInsn(Opcodes.GOTO, l2); // } cv_set_value.visitLabel(l0); // else { - cv_set_value.visitFrame(Opcodes.valueInt("F_SAME"), 0, null, 0, null); + cv_set_value.visitFrame(Opcodes.F_SAME, 0, null, 0, null); // foo = null; - cv_set_value.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_set_value.visitInsn(Opcodes.valueInt("ACONST_NULL")); - cv_set_value.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), className, attributeDetails.attributeName, attributeDetails.getReferenceClassType().getDescriptor()); + cv_set_value.visitVarInsn(Opcodes.ALOAD, 0); + cv_set_value.visitInsn(Opcodes.ACONST_NULL); + cv_set_value.visitFieldInsn(Opcodes.PUTFIELD, className, attributeDetails.attributeName, attributeDetails.getReferenceClassType().getDescriptor()); //} cv_set_value.visitLabel(l2); - cv_set_value.visitFrame(Opcodes.valueInt("F_SAME"), 0, null, 0, null); + cv_set_value.visitFrame(Opcodes.F_SAME, 0, null, 0, null); } - cv_set_value.visitInsn(Opcodes.valueInt("RETURN")); + cv_set_value.visitInsn(Opcodes.RETURN); cv_set_value.visitMaxs(0, 0); } @@ -555,43 +556,43 @@ public void addSetterMethodForFieldAccess(ClassDetails classDetails, AttributeDe String attribute = attributeDetails.getAttributeName(); // create _persistence_set_variableName - MethodVisitor cv_set = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), PERSISTENCE_SET + attribute, "(" + attributeDetails.getReferenceClassType().getDescriptor() + ")V", null, null); + MethodVisitor cv_set = cv.visitMethod(Opcodes.ACC_PUBLIC, PERSISTENCE_SET + attribute, "(" + attributeDetails.getReferenceClassType().getDescriptor() + ")V", null, null); // Get the opcode for the load instruction. This may be different // depending on the type - int opcode = attributeDetails.getReferenceClassType().getOpcode(Opcodes.valueInt("ILOAD")); + int opcode = attributeDetails.getReferenceClassType().getOpcode(Opcodes.ILOAD); if (classDetails.shouldWeaveFetchGroups()) { - cv_set.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); + cv_set.visitVarInsn(Opcodes.ALOAD, 0); cv_set.visitLdcInsn(attribute); // _persistence_checkFetchedForSet("variableName"); - cv_set.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), classDetails.getClassName(), "_persistence_checkFetchedForSet", "(Ljava/lang/String;)V", false); + cv_set.visitMethodInsn(Opcodes.INVOKEVIRTUAL, classDetails.getClassName(), "_persistence_checkFetchedForSet", "(Ljava/lang/String;)V", false); } if (classDetails.shouldWeaveChangeTracking()) { if (attributeDetails.weaveValueHolders()) { // _persistence_initialize_variableName_vh(); - cv_set.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_set.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), classDetails.getClassName(), "_persistence_initialize_" + attributeDetails.getAttributeName() + PERSISTENCE_FIELDNAME_POSTFIX, "()V", false); + cv_set.visitVarInsn(Opcodes.ALOAD, 0); + cv_set.visitMethodInsn(Opcodes.INVOKEVIRTUAL, classDetails.getClassName(), "_persistence_initialize_" + attributeDetails.getAttributeName() + PERSISTENCE_FIELDNAME_POSTFIX, "()V", false); // _persistenc_variableName_vh.getValue(); - cv_set.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_set.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_set.visitFieldInsn(Opcodes.valueInt("GETFIELD"), classDetails.getClassName(), PERSISTENCE_FIELDNAME_PREFIX + attribute + PERSISTENCE_FIELDNAME_POSTFIX, ClassWeaver.VHI_SIGNATURE); - cv_set.visitMethodInsn(Opcodes.valueInt("INVOKEINTERFACE"), ClassWeaver.VHI_SHORT_SIGNATURE, "getValue", "()Ljava/lang/Object;", true); + cv_set.visitVarInsn(Opcodes.ALOAD, 0); + cv_set.visitVarInsn(Opcodes.ALOAD, 0); + cv_set.visitFieldInsn(Opcodes.GETFIELD, classDetails.getClassName(), PERSISTENCE_FIELDNAME_PREFIX + attribute + PERSISTENCE_FIELDNAME_POSTFIX, ClassWeaver.VHI_SIGNATURE); + cv_set.visitMethodInsn(Opcodes.INVOKEINTERFACE, ClassWeaver.VHI_SHORT_SIGNATURE, "getValue", "()Ljava/lang/Object;", true); // Add the cast: // ()_persistenc_variableName_vh.getValue() - cv_set.visitTypeInsn(Opcodes.valueInt("CHECKCAST"), attributeDetails.getReferenceClassName().replace('.', '/')); + cv_set.visitTypeInsn(Opcodes.CHECKCAST, attributeDetails.getReferenceClassName().replace('.', '/')); // add the assignment: this.variableName = // ()_persistenc_variableName_vh.getValue(); - cv_set.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), classDetails.getClassName(), attribute, attributeDetails.getReferenceClassType().getDescriptor()); + cv_set.visitFieldInsn(Opcodes.PUTFIELD, classDetails.getClassName(), attribute, attributeDetails.getReferenceClassType().getDescriptor()); } // load the string attribute name as the first argument of the // property change call - cv_set.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); + cv_set.visitVarInsn(Opcodes.ALOAD, 0); cv_set.visitLdcInsn(attribute); // if the attribute is a primitive, wrap it @@ -599,70 +600,70 @@ public void addSetterMethodForFieldAccess(ClassDetails classDetails, AttributeDe // This is the first part of the wrapping String wrapper = ClassWeaver.wrapperFor(attributeDetails.getReferenceClassType().getSort()); if (wrapper != null) { - cv_set.visitTypeInsn(Opcodes.valueInt("NEW"), wrapper); - cv_set.visitInsn(Opcodes.valueInt("DUP")); + cv_set.visitTypeInsn(Opcodes.NEW, wrapper); + cv_set.visitInsn(Opcodes.DUP); } // load the method argument - cv_set.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_set.visitFieldInsn(Opcodes.valueInt("GETFIELD"), classDetails.getClassName(), attribute, attributeDetails.getReferenceClassType().getDescriptor()); + cv_set.visitVarInsn(Opcodes.ALOAD, 0); + cv_set.visitFieldInsn(Opcodes.GETFIELD, classDetails.getClassName(), attribute, attributeDetails.getReferenceClassType().getDescriptor()); if (wrapper != null) { // invoke the constructor for wrapping // e.g. Integer.valueOf(variableName) - cv_set.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), wrapper, "", "(" + attributeDetails.getReferenceClassType().getDescriptor() + ")V", false); + cv_set.visitMethodInsn(Opcodes.INVOKESPECIAL, wrapper, "", "(" + attributeDetails.getReferenceClassType().getDescriptor() + ")V", false); // wrap the method argument // e.g. Integer.valueOf(argument) - cv_set.visitTypeInsn(Opcodes.valueInt("NEW"), wrapper); - cv_set.visitInsn(Opcodes.valueInt("DUP")); + cv_set.visitTypeInsn(Opcodes.NEW, wrapper); + cv_set.visitInsn(Opcodes.DUP); cv_set.visitVarInsn(opcode, 1); - cv_set.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), wrapper, "", "(" + attributeDetails.getReferenceClassType().getDescriptor() + ")V", false); + cv_set.visitMethodInsn(Opcodes.INVOKESPECIAL, wrapper, "", "(" + attributeDetails.getReferenceClassType().getDescriptor() + ")V", false); } else { // if we are not wrapping the argument, just load it - cv_set.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); + cv_set.visitVarInsn(Opcodes.ALOAD, 1); } // _persistence_propertyChange("variableName", variableName, // argument); - cv_set.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), classDetails.getClassName(), "_persistence_propertyChange", "(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V", false); + cv_set.visitMethodInsn(Opcodes.INVOKEVIRTUAL, classDetails.getClassName(), "_persistence_propertyChange", "(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V", false); } else { if (attributeDetails.weaveValueHolders()) { // _persistence_initialize_variableName_vh(); - cv_set.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_set.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), classDetails.getClassName(), "_persistence_initialize_" + attributeDetails.getAttributeName() + PERSISTENCE_FIELDNAME_POSTFIX, "()V", false); + cv_set.visitVarInsn(Opcodes.ALOAD, 0); + cv_set.visitMethodInsn(Opcodes.INVOKEVIRTUAL, classDetails.getClassName(), "_persistence_initialize_" + attributeDetails.getAttributeName() + PERSISTENCE_FIELDNAME_POSTFIX, "()V", false); // _persistenc_variableName_vh.getValue(); - cv_set.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_set.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_set.visitFieldInsn(Opcodes.valueInt("GETFIELD"), classDetails.getClassName(), PERSISTENCE_FIELDNAME_PREFIX + attribute + PERSISTENCE_FIELDNAME_POSTFIX, ClassWeaver.VHI_SIGNATURE); - cv_set.visitMethodInsn(Opcodes.valueInt("INVOKEINTERFACE"), ClassWeaver.VHI_SHORT_SIGNATURE, "getValue", "()Ljava/lang/Object;", true); + cv_set.visitVarInsn(Opcodes.ALOAD, 0); + cv_set.visitVarInsn(Opcodes.ALOAD, 0); + cv_set.visitFieldInsn(Opcodes.GETFIELD, classDetails.getClassName(), PERSISTENCE_FIELDNAME_PREFIX + attribute + PERSISTENCE_FIELDNAME_POSTFIX, ClassWeaver.VHI_SIGNATURE); + cv_set.visitMethodInsn(Opcodes.INVOKEINTERFACE, ClassWeaver.VHI_SHORT_SIGNATURE, "getValue", "()Ljava/lang/Object;", true); // Add the cast: // ()_persistenc_variableName_vh.getValue() - cv_set.visitTypeInsn(Opcodes.valueInt("CHECKCAST"), attributeDetails.getReferenceClassName().replace('.', '/')); + cv_set.visitTypeInsn(Opcodes.CHECKCAST, attributeDetails.getReferenceClassName().replace('.', '/')); // add the assignment: this.variableName = // ()_persistenc_variableName_vh.getValue(); - cv_set.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), classDetails.getClassName(), attribute, attributeDetails.getReferenceClassType().getDescriptor()); + cv_set.visitFieldInsn(Opcodes.PUTFIELD, classDetails.getClassName(), attribute, attributeDetails.getReferenceClassType().getDescriptor()); } } // Must set variable after raising change event, so event has old and // new value. // variableName = argument - cv_set.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); + cv_set.visitVarInsn(Opcodes.ALOAD, 0); cv_set.visitVarInsn(opcode, 1); - cv_set.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), classDetails.getClassName(), attribute, attributeDetails.getReferenceClassType().getDescriptor()); + cv_set.visitFieldInsn(Opcodes.PUTFIELD, classDetails.getClassName(), attribute, attributeDetails.getReferenceClassType().getDescriptor()); if (attributeDetails.weaveValueHolders()) { // _persistence_variableName_vh.setValue(argument); - cv_set.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_set.visitFieldInsn(Opcodes.valueInt("GETFIELD"), classDetails.getClassName(), PERSISTENCE_FIELDNAME_PREFIX + attribute + PERSISTENCE_FIELDNAME_POSTFIX, ClassWeaver.VHI_SIGNATURE); - cv_set.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - cv_set.visitMethodInsn(Opcodes.valueInt("INVOKEINTERFACE"), ClassWeaver.VHI_SHORT_SIGNATURE, "setValue", "(Ljava/lang/Object;)V", true); + cv_set.visitVarInsn(Opcodes.ALOAD, 0); + cv_set.visitFieldInsn(Opcodes.GETFIELD, classDetails.getClassName(), PERSISTENCE_FIELDNAME_PREFIX + attribute + PERSISTENCE_FIELDNAME_POSTFIX, ClassWeaver.VHI_SIGNATURE); + cv_set.visitVarInsn(Opcodes.ALOAD, 1); + cv_set.visitMethodInsn(Opcodes.INVOKEINTERFACE, ClassWeaver.VHI_SHORT_SIGNATURE, "setValue", "(Ljava/lang/Object;)V", true); } - cv_set.visitInsn(Opcodes.valueInt("RETURN")); + cv_set.visitInsn(Opcodes.RETURN); cv_set.visitMaxs(0, 0); } @@ -680,41 +681,41 @@ public void addGetterMethodForFieldAccess(ClassDetails classDetails, AttributeDe String attribute = attributeDetails.getAttributeName(); // create the _persistenc_getvariableName method - MethodVisitor cv_get = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), PERSISTENCE_GET + attribute, "()" + attributeDetails.getReferenceClassType().getDescriptor(), null, null); + MethodVisitor cv_get = cv.visitMethod(Opcodes.ACC_PUBLIC, PERSISTENCE_GET + attribute, "()" + attributeDetails.getReferenceClassType().getDescriptor(), null, null); if (classDetails.shouldWeaveFetchGroups()) { - cv_get.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); + cv_get.visitVarInsn(Opcodes.ALOAD, 0); cv_get.visitLdcInsn(attribute); // _persistence_checkFetched("variableName"); - cv_get.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), classDetails.getClassName(), "_persistence_checkFetched", "(Ljava/lang/String;)V", false); + cv_get.visitMethodInsn(Opcodes.INVOKEVIRTUAL, classDetails.getClassName(), "_persistence_checkFetched", "(Ljava/lang/String;)V", false); } if (attributeDetails.weaveValueHolders()) { // _persistence_initialize_variableName_vh(); - cv_get.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_get.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), classDetails.getClassName(), "_persistence_initialize_" + attributeDetails.getAttributeName() + PERSISTENCE_FIELDNAME_POSTFIX, "()V", false); + cv_get.visitVarInsn(Opcodes.ALOAD, 0); + cv_get.visitMethodInsn(Opcodes.INVOKEVIRTUAL, classDetails.getClassName(), "_persistence_initialize_" + attributeDetails.getAttributeName() + PERSISTENCE_FIELDNAME_POSTFIX, "()V", false); // _persistenc_variableName_vh.getValue(); - cv_get.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_get.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_get.visitFieldInsn(Opcodes.valueInt("GETFIELD"), classDetails.getClassName(), PERSISTENCE_FIELDNAME_PREFIX + attribute + PERSISTENCE_FIELDNAME_POSTFIX, ClassWeaver.VHI_SIGNATURE); - cv_get.visitMethodInsn(Opcodes.valueInt("INVOKEINTERFACE"), ClassWeaver.VHI_SHORT_SIGNATURE, "getValue", "()Ljava/lang/Object;", true); + cv_get.visitVarInsn(Opcodes.ALOAD, 0); + cv_get.visitVarInsn(Opcodes.ALOAD, 0); + cv_get.visitFieldInsn(Opcodes.GETFIELD, classDetails.getClassName(), PERSISTENCE_FIELDNAME_PREFIX + attribute + PERSISTENCE_FIELDNAME_POSTFIX, ClassWeaver.VHI_SIGNATURE); + cv_get.visitMethodInsn(Opcodes.INVOKEINTERFACE, ClassWeaver.VHI_SHORT_SIGNATURE, "getValue", "()Ljava/lang/Object;", true); // Add the cast: // ()_persistenc_variableName_vh.getValue() - cv_get.visitTypeInsn(Opcodes.valueInt("CHECKCAST"), attributeDetails.getReferenceClassName().replace('.', '/')); + cv_get.visitTypeInsn(Opcodes.CHECKCAST, attributeDetails.getReferenceClassName().replace('.', '/')); // add the assignment: this.variableName = // ()_persistenc_variableName_vh.getValue(); - cv_get.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), classDetails.getClassName(), attribute, attributeDetails.getReferenceClassType().getDescriptor()); + cv_get.visitFieldInsn(Opcodes.PUTFIELD, classDetails.getClassName(), attribute, attributeDetails.getReferenceClassType().getDescriptor()); } // return this.variableName; - cv_get.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_get.visitFieldInsn(Opcodes.valueInt("GETFIELD"), classDetails.getClassName(), attribute, attributeDetails.getReferenceClassType().getDescriptor()); + cv_get.visitVarInsn(Opcodes.ALOAD, 0); + cv_get.visitFieldInsn(Opcodes.GETFIELD, classDetails.getClassName(), attribute, attributeDetails.getReferenceClassType().getDescriptor()); // Get the opcode for the return insturction. This may be different // depending on the type. - int opcode = attributeDetails.getReferenceClassType().getOpcode(Opcodes.valueInt("IRETURN")); + int opcode = attributeDetails.getReferenceClassType().getOpcode(Opcodes.IRETURN); cv_get.visitInsn(opcode); cv_get.visitMaxs(0, 0); } @@ -727,8 +728,8 @@ public void addGetterMethodForFieldAccess(ClassDetails classDetails, AttributeDe * private Object _persistence_primaryKey; */ public void addPersistenceEntityVariables() { - cv.visitField(Opcodes.valueInt("ACC_PROTECTED") + Opcodes.valueInt("ACC_TRANSIENT"), "_persistence_primaryKey", OBJECT_SIGNATURE, null, null); - cv.visitField(Opcodes.valueInt("ACC_PROTECTED") + Opcodes.valueInt("ACC_TRANSIENT"), "_persistence_cacheKey", CACHEKEY_SIGNATURE, null, null); + cv.visitField(Opcodes.ACC_PROTECTED + Opcodes.ACC_TRANSIENT, "_persistence_primaryKey", OBJECT_SIGNATURE, null, null); + cv.visitField(Opcodes.ACC_PROTECTED + Opcodes.ACC_TRANSIENT, "_persistence_cacheKey", CACHEKEY_SIGNATURE, null, null); } /** @@ -741,14 +742,14 @@ public void addPersistenceEntityVariables() { */ public void addPersistencePostClone(ClassDetails classDetails) { // create the _persistence_post_clone() method - MethodVisitor cv_clone = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "_persistence_post_clone", "()Ljava/lang/Object;", null, null); + MethodVisitor cv_clone = cv.visitMethod(Opcodes.ACC_PUBLIC, "_persistence_post_clone", "()Ljava/lang/Object;", null, null); // if there is a weaved superclass, it will implement // _persistence_post_clone. Call that method // super._persistence_post_clone() if (classDetails.getSuperClassDetails() != null && classDetails.getSuperClassDetails().shouldWeaveInternal()) { - cv_clone.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_clone.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), classDetails.getSuperClassName(), "_persistence_post_clone", "()Ljava/lang/Object;", false); + cv_clone.visitVarInsn(Opcodes.ALOAD, 0); + cv_clone.visitMethodInsn(Opcodes.INVOKESPECIAL, classDetails.getSuperClassName(), "_persistence_post_clone", "()Ljava/lang/Object;", false); } if (classDetails.shouldWeaveValueHolders()) { @@ -758,47 +759,47 @@ public void addPersistencePostClone(ClassDetails classDetails) { // !attributeDetails.isAttributeOnSuperClass()) // { // clone._attribute_vh = this._attribute_vh.clone(); - cv_clone.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_clone.visitFieldInsn(Opcodes.valueInt("GETFIELD"), classDetails.getClassName(), PERSISTENCE_FIELDNAME_PREFIX + attributeDetails.getAttributeName() + PERSISTENCE_FIELDNAME_POSTFIX, ClassWeaver.VHI_SIGNATURE); + cv_clone.visitVarInsn(Opcodes.ALOAD, 0); + cv_clone.visitFieldInsn(Opcodes.GETFIELD, classDetails.getClassName(), PERSISTENCE_FIELDNAME_PREFIX + attributeDetails.getAttributeName() + PERSISTENCE_FIELDNAME_POSTFIX, ClassWeaver.VHI_SIGNATURE); Label label = ASMFactory.createLabel(); - cv_clone.visitJumpInsn(Opcodes.valueInt("IFNULL"), label); - cv_clone.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_clone.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_clone.visitFieldInsn(Opcodes.valueInt("GETFIELD"), classDetails.getClassName(), PERSISTENCE_FIELDNAME_PREFIX + attributeDetails.getAttributeName() + PERSISTENCE_FIELDNAME_POSTFIX, ClassWeaver.VHI_SIGNATURE); - cv_clone.visitMethodInsn(Opcodes.valueInt("INVOKEINTERFACE"), ClassWeaver.VHI_SHORT_SIGNATURE, "clone", "()Ljava/lang/Object;", true); - cv_clone.visitTypeInsn(Opcodes.valueInt("CHECKCAST"), ClassWeaver.VHI_SHORT_SIGNATURE); - cv_clone.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), classDetails.getClassName(), PERSISTENCE_FIELDNAME_PREFIX + attributeDetails.getAttributeName() + PERSISTENCE_FIELDNAME_POSTFIX, ClassWeaver.VHI_SIGNATURE); + cv_clone.visitJumpInsn(Opcodes.IFNULL, label); + cv_clone.visitVarInsn(Opcodes.ALOAD, 0); + cv_clone.visitVarInsn(Opcodes.ALOAD, 0); + cv_clone.visitFieldInsn(Opcodes.GETFIELD, classDetails.getClassName(), PERSISTENCE_FIELDNAME_PREFIX + attributeDetails.getAttributeName() + PERSISTENCE_FIELDNAME_POSTFIX, ClassWeaver.VHI_SIGNATURE); + cv_clone.visitMethodInsn(Opcodes.INVOKEINTERFACE, ClassWeaver.VHI_SHORT_SIGNATURE, "clone", "()Ljava/lang/Object;", true); + cv_clone.visitTypeInsn(Opcodes.CHECKCAST, ClassWeaver.VHI_SHORT_SIGNATURE); + cv_clone.visitFieldInsn(Opcodes.PUTFIELD, classDetails.getClassName(), PERSISTENCE_FIELDNAME_PREFIX + attributeDetails.getAttributeName() + PERSISTENCE_FIELDNAME_POSTFIX, ClassWeaver.VHI_SIGNATURE); cv_clone.visitLabel(label); } } } if (classDetails.shouldWeaveChangeTracking()) { // clone._persistence_listener = null; - cv_clone.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_clone.visitInsn(Opcodes.valueInt("ACONST_NULL")); - cv_clone.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), classDetails.getClassName(), "_persistence_listener", PCL_SIGNATURE); + cv_clone.visitVarInsn(Opcodes.ALOAD, 0); + cv_clone.visitInsn(Opcodes.ACONST_NULL); + cv_clone.visitFieldInsn(Opcodes.PUTFIELD, classDetails.getClassName(), "_persistence_listener", PCL_SIGNATURE); } if (classDetails.shouldWeaveFetchGroups()) { // clone._persistence_fetchGroup = null; // clone._persistence_session = null; - cv_clone.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_clone.visitInsn(Opcodes.valueInt("ACONST_NULL")); - cv_clone.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), classDetails.getClassName(), "_persistence_fetchGroup", FETCHGROUP_SIGNATURE); - cv_clone.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_clone.visitInsn(Opcodes.valueInt("ACONST_NULL")); - cv_clone.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), classDetails.getClassName(), "_persistence_session", SESSION_SIGNATURE); + cv_clone.visitVarInsn(Opcodes.ALOAD, 0); + cv_clone.visitInsn(Opcodes.ACONST_NULL); + cv_clone.visitFieldInsn(Opcodes.PUTFIELD, classDetails.getClassName(), "_persistence_fetchGroup", FETCHGROUP_SIGNATURE); + cv_clone.visitVarInsn(Opcodes.ALOAD, 0); + cv_clone.visitInsn(Opcodes.ACONST_NULL); + cv_clone.visitFieldInsn(Opcodes.PUTFIELD, classDetails.getClassName(), "_persistence_session", SESSION_SIGNATURE); } if (!classDetails.isEmbedable()) { // clone._persistence_primaryKey = null; - cv_clone.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_clone.visitInsn(Opcodes.valueInt("ACONST_NULL")); - cv_clone.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), classDetails.getClassName(), "_persistence_primaryKey", OBJECT_SIGNATURE); + cv_clone.visitVarInsn(Opcodes.ALOAD, 0); + cv_clone.visitInsn(Opcodes.ACONST_NULL); + cv_clone.visitFieldInsn(Opcodes.PUTFIELD, classDetails.getClassName(), "_persistence_primaryKey", OBJECT_SIGNATURE); } // return clone; - cv_clone.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_clone.visitInsn(Opcodes.valueInt("ARETURN")); + cv_clone.visitVarInsn(Opcodes.ALOAD, 0); + cv_clone.visitInsn(Opcodes.ARETURN); cv_clone.visitMaxs(0, 0); } @@ -806,69 +807,69 @@ public void addPersistenceRestMethods(ClassDetails classDetails) { // public List _persistence_getRelationships() { // return this._persistence_relationshipInfo; // } - MethodVisitor cv_getPKVector = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), PERSISTENCE_FIELDNAME_PREFIX + "getRelationships", "()" + LIST_RELATIONSHIP_INFO_SIGNATURE, "()" + LIST_RELATIONSHIP_INFO_GENERIC_SIGNATURE, null); - cv_getPKVector.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_getPKVector.visitFieldInsn(Opcodes.valueInt("GETFIELD"), classDetails.getClassName(), "_persistence_relationshipInfo", LIST_RELATIONSHIP_INFO_SIGNATURE); - cv_getPKVector.visitInsn(Opcodes.valueInt("ARETURN")); + MethodVisitor cv_getPKVector = cv.visitMethod(Opcodes.ACC_PUBLIC, PERSISTENCE_FIELDNAME_PREFIX + "getRelationships", "()" + LIST_RELATIONSHIP_INFO_SIGNATURE, "()" + LIST_RELATIONSHIP_INFO_GENERIC_SIGNATURE, null); + cv_getPKVector.visitVarInsn(Opcodes.ALOAD, 0); + cv_getPKVector.visitFieldInsn(Opcodes.GETFIELD, classDetails.getClassName(), "_persistence_relationshipInfo", LIST_RELATIONSHIP_INFO_SIGNATURE); + cv_getPKVector.visitInsn(Opcodes.ARETURN); cv_getPKVector.visitMaxs(0, 0); // public void _persistence_setRelationships(List paramList) { // this._persistence_relationshipInfo = paramList; // } - MethodVisitor cv_setPKVector = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), PERSISTENCE_FIELDNAME_PREFIX + "setRelationships", "(" + LIST_RELATIONSHIP_INFO_SIGNATURE + ")V", "(" + LIST_RELATIONSHIP_INFO_GENERIC_SIGNATURE + ")V", null); - cv_setPKVector.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_setPKVector.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - cv_setPKVector.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), classDetails.getClassName(), PERSISTENCE_FIELDNAME_PREFIX + "relationshipInfo", LIST_RELATIONSHIP_INFO_SIGNATURE); - cv_setPKVector.visitInsn(Opcodes.valueInt("RETURN")); + MethodVisitor cv_setPKVector = cv.visitMethod(Opcodes.ACC_PUBLIC, PERSISTENCE_FIELDNAME_PREFIX + "setRelationships", "(" + LIST_RELATIONSHIP_INFO_SIGNATURE + ")V", "(" + LIST_RELATIONSHIP_INFO_GENERIC_SIGNATURE + ")V", null); + cv_setPKVector.visitVarInsn(Opcodes.ALOAD, 0); + cv_setPKVector.visitVarInsn(Opcodes.ALOAD, 1); + cv_setPKVector.visitFieldInsn(Opcodes.PUTFIELD, classDetails.getClassName(), PERSISTENCE_FIELDNAME_PREFIX + "relationshipInfo", LIST_RELATIONSHIP_INFO_SIGNATURE); + cv_setPKVector.visitInsn(Opcodes.RETURN); cv_setPKVector.visitMaxs(0, 0); // public Link _persistence_getHref() { // return this._persistence_href; // } - MethodVisitor cv_getHref = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), PERSISTENCE_FIELDNAME_PREFIX + "getHref", "()" + LINK_SIGNATURE, null, null); - cv_getHref.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_getHref.visitFieldInsn(Opcodes.valueInt("GETFIELD"), classDetails.getClassName(), PERSISTENCE_FIELDNAME_PREFIX + "href", LINK_SIGNATURE); - cv_getHref.visitInsn(Opcodes.valueInt("ARETURN")); + MethodVisitor cv_getHref = cv.visitMethod(Opcodes.ACC_PUBLIC, PERSISTENCE_FIELDNAME_PREFIX + "getHref", "()" + LINK_SIGNATURE, null, null); + cv_getHref.visitVarInsn(Opcodes.ALOAD, 0); + cv_getHref.visitFieldInsn(Opcodes.GETFIELD, classDetails.getClassName(), PERSISTENCE_FIELDNAME_PREFIX + "href", LINK_SIGNATURE); + cv_getHref.visitInsn(Opcodes.ARETURN); cv_getHref.visitMaxs(0, 0); // public void _persistence_setHref(Link paramLink) // this._persistence_href = paramLink; // } - MethodVisitor cv_setHref = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), PERSISTENCE_FIELDNAME_PREFIX + "setHref", "(" + LINK_SIGNATURE + ")V", null, null); - cv_setHref.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_setHref.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - cv_setHref.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), classDetails.getClassName(), PERSISTENCE_FIELDNAME_PREFIX + "href", LINK_SIGNATURE); - cv_setHref.visitInsn(Opcodes.valueInt("RETURN")); + MethodVisitor cv_setHref = cv.visitMethod(Opcodes.ACC_PUBLIC, PERSISTENCE_FIELDNAME_PREFIX + "setHref", "(" + LINK_SIGNATURE + ")V", null, null); + cv_setHref.visitVarInsn(Opcodes.ALOAD, 0); + cv_setHref.visitVarInsn(Opcodes.ALOAD, 1); + cv_setHref.visitFieldInsn(Opcodes.PUTFIELD, classDetails.getClassName(), PERSISTENCE_FIELDNAME_PREFIX + "href", LINK_SIGNATURE); + cv_setHref.visitInsn(Opcodes.RETURN); cv_setHref.visitMaxs(0, 0); // public ItemLinks _persistence_getLinks() { // return this._persistence_links; // } - MethodVisitor cv_getLinks = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), PERSISTENCE_FIELDNAME_PREFIX + "getLinks", "()" + ITEM_LINKS_SIGNATURE, null, null); - cv_getLinks.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_getLinks.visitFieldInsn(Opcodes.valueInt("GETFIELD"), classDetails.getClassName(), PERSISTENCE_FIELDNAME_PREFIX + "links", ITEM_LINKS_SIGNATURE); - cv_getLinks.visitInsn(Opcodes.valueInt("ARETURN")); + MethodVisitor cv_getLinks = cv.visitMethod(Opcodes.ACC_PUBLIC, PERSISTENCE_FIELDNAME_PREFIX + "getLinks", "()" + ITEM_LINKS_SIGNATURE, null, null); + cv_getLinks.visitVarInsn(Opcodes.ALOAD, 0); + cv_getLinks.visitFieldInsn(Opcodes.GETFIELD, classDetails.getClassName(), PERSISTENCE_FIELDNAME_PREFIX + "links", ITEM_LINKS_SIGNATURE); + cv_getLinks.visitInsn(Opcodes.ARETURN); cv_getLinks.visitMaxs(0, 0); // public void _persistence_setLinks(ItemLinks paramItemLinks) { // this._persistence_links = paramItemLinks; // } - MethodVisitor cv_setLinks = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), PERSISTENCE_FIELDNAME_PREFIX + "setLinks", "(" + ITEM_LINKS_SIGNATURE + ")V", null, null); - cv_setLinks.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_setLinks.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - cv_setLinks.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), classDetails.getClassName(), PERSISTENCE_FIELDNAME_PREFIX + "links", ITEM_LINKS_SIGNATURE); - cv_setLinks.visitInsn(Opcodes.valueInt("RETURN")); + MethodVisitor cv_setLinks = cv.visitMethod(Opcodes.ACC_PUBLIC, PERSISTENCE_FIELDNAME_PREFIX + "setLinks", "(" + ITEM_LINKS_SIGNATURE + ")V", null, null); + cv_setLinks.visitVarInsn(Opcodes.ALOAD, 0); + cv_setLinks.visitVarInsn(Opcodes.ALOAD, 1); + cv_setLinks.visitFieldInsn(Opcodes.PUTFIELD, classDetails.getClassName(), PERSISTENCE_FIELDNAME_PREFIX + "links", ITEM_LINKS_SIGNATURE); + cv_setLinks.visitInsn(Opcodes.RETURN); cv_setLinks.visitMaxs(0, 0); } public void addPersistenceRestVariables() { // protected transient List _persistence_relationshipInfo; - cv.visitField(Opcodes.valueInt("ACC_PROTECTED") | Opcodes.valueInt("ACC_TRANSIENT"), PERSISTENCE_FIELDNAME_PREFIX + "relationshipInfo", LIST_RELATIONSHIP_INFO_SIGNATURE, LIST_RELATIONSHIP_INFO_GENERIC_SIGNATURE, null); + cv.visitField(Opcodes.ACC_PROTECTED | Opcodes.ACC_TRANSIENT, PERSISTENCE_FIELDNAME_PREFIX + "relationshipInfo", LIST_RELATIONSHIP_INFO_SIGNATURE, LIST_RELATIONSHIP_INFO_GENERIC_SIGNATURE, null); // protected transient Link _persistence_href; - cv.visitField(Opcodes.valueInt("ACC_PROTECTED") | Opcodes.valueInt("ACC_TRANSIENT"), PERSISTENCE_FIELDNAME_PREFIX + "href", LINK_SIGNATURE, null, null); + cv.visitField(Opcodes.ACC_PROTECTED | Opcodes.ACC_TRANSIENT, PERSISTENCE_FIELDNAME_PREFIX + "href", LINK_SIGNATURE, null, null); // protected transient ItemLinks _persistence_links; - cv.visitField(Opcodes.valueInt("ACC_PROTECTED") | Opcodes.valueInt("ACC_TRANSIENT"), PERSISTENCE_FIELDNAME_PREFIX + "links", ITEM_LINKS_SIGNATURE, null, null); + cv.visitField(Opcodes.ACC_PROTECTED | Opcodes.ACC_TRANSIENT, PERSISTENCE_FIELDNAME_PREFIX + "links", ITEM_LINKS_SIGNATURE, null, null); } /** @@ -879,13 +880,13 @@ public void addPersistenceRestVariables() { */ public void addShallowClone(ClassDetails classDetails) { // create the _persistence_shallow_clone() method - MethodVisitor cv_clone = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "_persistence_shallow_clone", "()Ljava/lang/Object;", null, null); + MethodVisitor cv_clone = cv.visitMethod(Opcodes.ACC_PUBLIC, "_persistence_shallow_clone", "()Ljava/lang/Object;", null, null); // return super.clone(); - cv_clone.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_clone.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), "java/lang/Object", "clone", "()Ljava/lang/Object;", false); + cv_clone.visitVarInsn(Opcodes.ALOAD, 0); + cv_clone.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "clone", "()Ljava/lang/Object;", false); - cv_clone.visitInsn(Opcodes.valueInt("ARETURN")); + cv_clone.visitInsn(Opcodes.ARETURN); cv_clone.visitMaxs(0, 0); } @@ -900,36 +901,37 @@ public void addShallowClone(ClassDetails classDetails) { */ public void addPersistenceNew(ClassDetails classDetails) { // create the _persistence_new() method - MethodVisitor cv_new = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "_persistence_new", "(" + PERSISTENCE_OBJECT_SIGNATURE + ")Ljava/lang/Object;", null, null); + MethodVisitor cv_new = cv.visitMethod(Opcodes.ACC_PUBLIC, "_persistence_new", "(" + PERSISTENCE_OBJECT_SIGNATURE + ")Ljava/lang/Object;", null, null); // return new ClassType(factory); - cv_new.visitTypeInsn(Opcodes.valueInt("NEW"), classDetails.getClassName()); - cv_new.visitInsn(Opcodes.valueInt("DUP")); + cv_new.visitTypeInsn(Opcodes.NEW, classDetails.getClassName()); + cv_new.visitInsn(Opcodes.DUP); if (!classDetails.canWeaveConstructorOptimization()) { - cv_new.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), classDetails.getClassName(), "", "()V", false); - cv_new.visitInsn(Opcodes.valueInt("ARETURN")); + cv_new.visitMethodInsn(Opcodes.INVOKESPECIAL, classDetails.getClassName(), "", "()V", false); + cv_new.visitInsn(Opcodes.ARETURN); cv_new.visitMaxs(0, 0); return; } else { - cv_new.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - cv_new.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), classDetails.getClassName(), "", "(" + PERSISTENCE_OBJECT_SIGNATURE + ")V", false); + cv_new.visitVarInsn(Opcodes.ALOAD, 1); + cv_new.visitMethodInsn(Opcodes.INVOKESPECIAL, classDetails.getClassName(), "", "(" + PERSISTENCE_OBJECT_SIGNATURE + ")V", false); } - cv_new.visitInsn(Opcodes.valueInt("ARETURN")); + cv_new.visitInsn(Opcodes.ARETURN); cv_new.visitMaxs(0, 0); // create the ClassType() method - MethodVisitor cv_constructor = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "", "(" + PERSISTENCE_OBJECT_SIGNATURE + ")V", null, null); + MethodVisitor cv_constructor = cv.visitMethod(Opcodes.ACC_PUBLIC, "", "(" + PERSISTENCE_OBJECT_SIGNATURE + ")V", null, null); + + cv_constructor.visitVarInsn(Opcodes.ALOAD, 0); - cv_constructor.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); if (classDetails.getSuperClassDetails() == null) { // super(); - cv_constructor.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), classDetails.getSuperClassName(), "", "()V", false); + cv_constructor.visitMethodInsn(Opcodes.INVOKESPECIAL, classDetails.getSuperClassName(), "", "()V", false); } else { // super(factory); - cv_constructor.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - cv_constructor.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), classDetails.getSuperClassName(), "", "(" + PERSISTENCE_OBJECT_SIGNATURE + ")V", false); + cv_constructor.visitVarInsn(Opcodes.ALOAD, 1); + cv_constructor.visitMethodInsn(Opcodes.INVOKESPECIAL, classDetails.getSuperClassName(), "", "(" + PERSISTENCE_OBJECT_SIGNATURE + ")V", false); } - cv_constructor.visitInsn(Opcodes.valueInt("RETURN")); + cv_constructor.visitInsn(Opcodes.RETURN); cv_constructor.visitMaxs(0, 0); } @@ -947,7 +949,7 @@ public void addPersistenceNew(ClassDetails classDetails) { */ public void addPersistenceGetSet(ClassDetails classDetails) { // create the _persistence_get() method - MethodVisitor cv_get = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "_persistence_get", "(Ljava/lang/String;)Ljava/lang/Object;", null, null); + MethodVisitor cv_get = cv.visitMethod(Opcodes.ACC_PUBLIC, "_persistence_get", "(Ljava/lang/String;)Ljava/lang/Object;", null, null); Label label = null; for (AttributeDetails attributeDetails : classDetails.getAttributesMap().values()) { @@ -956,22 +958,22 @@ public void addPersistenceGetSet(ClassDetails classDetails) { cv_get.visitLabel(label); } // else if (attribute == "address") - cv_get.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); + cv_get.visitVarInsn(Opcodes.ALOAD, 1); cv_get.visitLdcInsn(attributeDetails.getAttributeName().intern()); label = ASMFactory.createLabel(); - cv_get.visitJumpInsn(Opcodes.valueInt("IF_ACMPNE"), label); + cv_get.visitJumpInsn(Opcodes.IF_ACMPNE, label); // return this.address - cv_get.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_get.visitFieldInsn(Opcodes.valueInt("GETFIELD"), classDetails.getClassName(), attributeDetails.getAttributeName(), attributeDetails.getReferenceClassType().getDescriptor()); + cv_get.visitVarInsn(Opcodes.ALOAD, 0); + cv_get.visitFieldInsn(Opcodes.GETFIELD, classDetails.getClassName(), attributeDetails.getAttributeName(), attributeDetails.getReferenceClassType().getDescriptor()); // if this is a primitive, get the wrapper class String wrapper = ClassWeaver.wrapperFor(attributeDetails.getReferenceClassType().getSort()); if (wrapper != null) { // Call valueOf on the wrapper (more optimal than // constructor). - cv_get.visitMethodInsn(Opcodes.valueInt("INVOKESTATIC"), wrapper, "valueOf", "(" + attributeDetails.getReferenceClassType().getDescriptor() + ")L" + wrapper + ";", false); + cv_get.visitMethodInsn(Opcodes.INVOKESTATIC, wrapper, "valueOf", "(" + attributeDetails.getReferenceClassType().getDescriptor() + ")L" + wrapper + ";", false); } - cv_get.visitInsn(Opcodes.valueInt("ARETURN")); + cv_get.visitInsn(Opcodes.ARETURN); } } if (label != null) { @@ -980,18 +982,18 @@ public void addPersistenceGetSet(ClassDetails classDetails) { // call super, or return null if (classDetails.getSuperClassDetails() == null) { // return null; - cv_get.visitInsn(Opcodes.valueInt("ACONST_NULL")); + cv_get.visitInsn(Opcodes.ACONST_NULL); } else { - cv_get.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_get.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - cv_get.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), classDetails.getSuperClassName(), "_persistence_get", "(Ljava/lang/String;)Ljava/lang/Object;", false); + cv_get.visitVarInsn(Opcodes.ALOAD, 0); + cv_get.visitVarInsn(Opcodes.ALOAD, 1); + cv_get.visitMethodInsn(Opcodes.INVOKESPECIAL, classDetails.getSuperClassName(), "_persistence_get", "(Ljava/lang/String;)Ljava/lang/Object;", false); } - cv_get.visitInsn(Opcodes.valueInt("ARETURN")); + cv_get.visitInsn(Opcodes.ARETURN); cv_get.visitMaxs(0, 0); // create the _persistence_set() method - MethodVisitor cv_set = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "_persistence_set", "(Ljava/lang/String;Ljava/lang/Object;)V", null, null); + MethodVisitor cv_set = cv.visitMethod(Opcodes.ACC_PUBLIC, "_persistence_set", "(Ljava/lang/String;Ljava/lang/Object;)V", null, null); label = null; for (AttributeDetails attribute : classDetails.getAttributesMap().values()) { @@ -1000,23 +1002,23 @@ public void addPersistenceGetSet(ClassDetails classDetails) { cv_set.visitLabel(label); } // else if (attribute == "address") - cv_set.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); + cv_set.visitVarInsn(Opcodes.ALOAD, 1); cv_set.visitLdcInsn(attribute.getAttributeName().intern()); label = ASMFactory.createLabel(); - cv_set.visitJumpInsn(Opcodes.valueInt("IF_ACMPNE"), label); + cv_set.visitJumpInsn(Opcodes.IF_ACMPNE, label); // this.address = (String)value; - cv_set.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_set.visitVarInsn(Opcodes.valueInt("ALOAD"), 2); + cv_set.visitVarInsn(Opcodes.ALOAD, 0); + cv_set.visitVarInsn(Opcodes.ALOAD, 2); String wrapper = wrapperFor(attribute.getReferenceClassType().getSort()); if (wrapper == null) { wrapper = attribute.getReferenceClassName().replace('.', '/'); } - cv_set.visitTypeInsn(Opcodes.valueInt("CHECKCAST"), wrapper); + cv_set.visitTypeInsn(Opcodes.CHECKCAST, wrapper); // Unwrap any primitive wrapper to its value. unwrapPrimitive(attribute, cv_set); - cv_set.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), classDetails.getClassName(), attribute.getAttributeName(), attribute.getReferenceClassType().getDescriptor()); + cv_set.visitFieldInsn(Opcodes.PUTFIELD, classDetails.getClassName(), attribute.getAttributeName(), attribute.getReferenceClassType().getDescriptor()); // return; - cv_set.visitInsn(Opcodes.valueInt("RETURN")); + cv_set.visitInsn(Opcodes.RETURN); } } if (label != null) { @@ -1024,13 +1026,13 @@ public void addPersistenceGetSet(ClassDetails classDetails) { } // call super, or return null if (classDetails.getSuperClassDetails() != null) { - cv_set.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_set.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - cv_set.visitVarInsn(Opcodes.valueInt("ALOAD"), 2); - cv_set.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), classDetails.getSuperClassName(), "_persistence_set", "(Ljava/lang/String;Ljava/lang/Object;)V", false); + cv_set.visitVarInsn(Opcodes.ALOAD, 0); + cv_set.visitVarInsn(Opcodes.ALOAD, 1); + cv_set.visitVarInsn(Opcodes.ALOAD, 2); + cv_set.visitMethodInsn(Opcodes.INVOKESPECIAL, classDetails.getSuperClassName(), "_persistence_set", "(Ljava/lang/String;Ljava/lang/Object;)V", false); } - cv_set.visitInsn(Opcodes.valueInt("RETURN")); + cv_set.visitInsn(Opcodes.RETURN); cv_set.visitMaxs(0, 0); } @@ -1043,30 +1045,30 @@ public void addPersistenceGetSet(ClassDetails classDetails) { * this._persistence_primaryKey = primaryKey; } */ public void addPersistenceEntityMethods(ClassDetails classDetails) { - MethodVisitor cv_getPKVector = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "_persistence_getId", "()" + OBJECT_SIGNATURE, null, null); - cv_getPKVector.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_getPKVector.visitFieldInsn(Opcodes.valueInt("GETFIELD"), classDetails.getClassName(), "_persistence_primaryKey", OBJECT_SIGNATURE); - cv_getPKVector.visitInsn(Opcodes.valueInt("ARETURN")); + MethodVisitor cv_getPKVector = cv.visitMethod(Opcodes.ACC_PUBLIC, "_persistence_getId", "()" + OBJECT_SIGNATURE, null, null); + cv_getPKVector.visitVarInsn(Opcodes.ALOAD, 0); + cv_getPKVector.visitFieldInsn(Opcodes.GETFIELD, classDetails.getClassName(), "_persistence_primaryKey", OBJECT_SIGNATURE); + cv_getPKVector.visitInsn(Opcodes.ARETURN); cv_getPKVector.visitMaxs(0, 0); - MethodVisitor cv_setPKVector = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "_persistence_setId", "(" + OBJECT_SIGNATURE + ")V", null, null); - cv_setPKVector.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_setPKVector.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - cv_setPKVector.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), classDetails.getClassName(), "_persistence_primaryKey", OBJECT_SIGNATURE); - cv_setPKVector.visitInsn(Opcodes.valueInt("RETURN")); + MethodVisitor cv_setPKVector = cv.visitMethod(Opcodes.ACC_PUBLIC, "_persistence_setId", "(" + OBJECT_SIGNATURE + ")V", null, null); + cv_setPKVector.visitVarInsn(Opcodes.ALOAD, 0); + cv_setPKVector.visitVarInsn(Opcodes.ALOAD, 1); + cv_setPKVector.visitFieldInsn(Opcodes.PUTFIELD, classDetails.getClassName(), "_persistence_primaryKey", OBJECT_SIGNATURE); + cv_setPKVector.visitInsn(Opcodes.RETURN); cv_setPKVector.visitMaxs(0, 0); - MethodVisitor cv_getCacheKey = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "_persistence_getCacheKey", "()" + CACHEKEY_SIGNATURE, null, null); - cv_getCacheKey.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_getCacheKey.visitFieldInsn(Opcodes.valueInt("GETFIELD"), classDetails.getClassName(), "_persistence_cacheKey", CACHEKEY_SIGNATURE); - cv_getCacheKey.visitInsn(Opcodes.valueInt("ARETURN")); + MethodVisitor cv_getCacheKey = cv.visitMethod(Opcodes.ACC_PUBLIC, "_persistence_getCacheKey", "()" + CACHEKEY_SIGNATURE, null, null); + cv_getCacheKey.visitVarInsn(Opcodes.ALOAD, 0); + cv_getCacheKey.visitFieldInsn(Opcodes.GETFIELD, classDetails.getClassName(), "_persistence_cacheKey", CACHEKEY_SIGNATURE); + cv_getCacheKey.visitInsn(Opcodes.ARETURN); cv_getCacheKey.visitMaxs(0, 0); - MethodVisitor cv_setCacheKey = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "_persistence_setCacheKey", "(" + CACHEKEY_SIGNATURE + ")V", null, null); - cv_setCacheKey.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_setCacheKey.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - cv_setCacheKey.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), classDetails.getClassName(), "_persistence_cacheKey", CACHEKEY_SIGNATURE); - cv_setCacheKey.visitInsn(Opcodes.valueInt("RETURN")); + MethodVisitor cv_setCacheKey = cv.visitMethod(Opcodes.ACC_PUBLIC, "_persistence_setCacheKey", "(" + CACHEKEY_SIGNATURE + ")V", null, null); + cv_setCacheKey.visitVarInsn(Opcodes.ALOAD, 0); + cv_setCacheKey.visitVarInsn(Opcodes.ALOAD, 1); + cv_setCacheKey.visitFieldInsn(Opcodes.PUTFIELD, classDetails.getClassName(), "_persistence_cacheKey", CACHEKEY_SIGNATURE); + cv_setCacheKey.visitInsn(Opcodes.RETURN); cv_setCacheKey.visitMaxs(0, 0); } @@ -1080,7 +1082,7 @@ public void addPersistenceEntityMethods(ClassDetails classDetails) { * _persistence_session; */ public void addFetchGroupVariables() { - FieldVisitor fv = cv.visitField(Opcodes.valueInt("ACC_PROTECTED"), "_persistence_fetchGroup", FETCHGROUP_SIGNATURE, null, null); + FieldVisitor fv = cv.visitField(Opcodes.ACC_PROTECTED, "_persistence_fetchGroup", FETCHGROUP_SIGNATURE, null, null); // Only add jakarta.persistence.Transient annotation if attribute access // is being used if (classDetails.usesAttributeAccess()) { @@ -1091,8 +1093,8 @@ public void addFetchGroupVariables() { } fv.visitEnd(); - cv.visitField(Opcodes.valueInt("ACC_PROTECTED") + Opcodes.valueInt("ACC_TRANSIENT"), "_persistence_shouldRefreshFetchGroup", PBOOLEAN_SIGNATURE, null, null).visitEnd(); - cv.visitField(Opcodes.valueInt("ACC_PROTECTED") + Opcodes.valueInt("ACC_TRANSIENT"), "_persistence_session", SESSION_SIGNATURE, null, null).visitEnd(); + cv.visitField(Opcodes.ACC_PROTECTED + Opcodes.ACC_TRANSIENT, "_persistence_shouldRefreshFetchGroup", PBOOLEAN_SIGNATURE, null, null).visitEnd(); + cv.visitField(Opcodes.ACC_PROTECTED + Opcodes.ACC_TRANSIENT, "_persistence_session", SESSION_SIGNATURE, null, null).visitEnd(); } /** @@ -1129,96 +1131,96 @@ public void addFetchGroupVariables() { * EntityManagerImpl.processUnfetchedAttributeForSet(this, attribute); } } */ public void addFetchGroupMethods(ClassDetails classDetails) { - MethodVisitor cv_getSession = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "_persistence_getSession", "()" + SESSION_SIGNATURE, null, null); - cv_getSession.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_getSession.visitFieldInsn(Opcodes.valueInt("GETFIELD"), classDetails.getClassName(), "_persistence_session", SESSION_SIGNATURE); - cv_getSession.visitInsn(Opcodes.valueInt("ARETURN")); + MethodVisitor cv_getSession = cv.visitMethod(Opcodes.ACC_PUBLIC, "_persistence_getSession", "()" + SESSION_SIGNATURE, null, null); + cv_getSession.visitVarInsn(Opcodes.ALOAD, 0); + cv_getSession.visitFieldInsn(Opcodes.GETFIELD, classDetails.getClassName(), "_persistence_session", SESSION_SIGNATURE); + cv_getSession.visitInsn(Opcodes.ARETURN); cv_getSession.visitMaxs(0, 0); - MethodVisitor cv_setSession = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "_persistence_setSession", "(" + SESSION_SIGNATURE + ")V", null, null); - cv_setSession.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_setSession.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - cv_setSession.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), classDetails.getClassName(), "_persistence_session", SESSION_SIGNATURE); - cv_setSession.visitInsn(Opcodes.valueInt("RETURN")); + MethodVisitor cv_setSession = cv.visitMethod(Opcodes.ACC_PUBLIC, "_persistence_setSession", "(" + SESSION_SIGNATURE + ")V", null, null); + cv_setSession.visitVarInsn(Opcodes.ALOAD, 0); + cv_setSession.visitVarInsn(Opcodes.ALOAD, 1); + cv_setSession.visitFieldInsn(Opcodes.PUTFIELD, classDetails.getClassName(), "_persistence_session", SESSION_SIGNATURE); + cv_setSession.visitInsn(Opcodes.RETURN); cv_setSession.visitMaxs(0, 0); - MethodVisitor cv_getFetchGroup = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "_persistence_getFetchGroup", "()" + FETCHGROUP_SIGNATURE, null, null); - cv_getFetchGroup.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_getFetchGroup.visitFieldInsn(Opcodes.valueInt("GETFIELD"), classDetails.getClassName(), "_persistence_fetchGroup", FETCHGROUP_SIGNATURE); - cv_getFetchGroup.visitInsn(Opcodes.valueInt("ARETURN")); + MethodVisitor cv_getFetchGroup = cv.visitMethod(Opcodes.ACC_PUBLIC, "_persistence_getFetchGroup", "()" + FETCHGROUP_SIGNATURE, null, null); + cv_getFetchGroup.visitVarInsn(Opcodes.ALOAD, 0); + cv_getFetchGroup.visitFieldInsn(Opcodes.GETFIELD, classDetails.getClassName(), "_persistence_fetchGroup", FETCHGROUP_SIGNATURE); + cv_getFetchGroup.visitInsn(Opcodes.ARETURN); cv_getFetchGroup.visitMaxs(0, 0); - MethodVisitor cv_setFetchGroup = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "_persistence_setFetchGroup", "(" + FETCHGROUP_SIGNATURE + ")V", null, null); - cv_setFetchGroup.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_setFetchGroup.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - cv_setFetchGroup.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), classDetails.getClassName(), "_persistence_fetchGroup", FETCHGROUP_SIGNATURE); - cv_setFetchGroup.visitInsn(Opcodes.valueInt("RETURN")); + MethodVisitor cv_setFetchGroup = cv.visitMethod(Opcodes.ACC_PUBLIC, "_persistence_setFetchGroup", "(" + FETCHGROUP_SIGNATURE + ")V", null, null); + cv_setFetchGroup.visitVarInsn(Opcodes.ALOAD, 0); + cv_setFetchGroup.visitVarInsn(Opcodes.ALOAD, 1); + cv_setFetchGroup.visitFieldInsn(Opcodes.PUTFIELD, classDetails.getClassName(), "_persistence_fetchGroup", FETCHGROUP_SIGNATURE); + cv_setFetchGroup.visitInsn(Opcodes.RETURN); cv_setFetchGroup.visitMaxs(0, 0); - MethodVisitor cv_shouldRefreshFetchGroup = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "_persistence_shouldRefreshFetchGroup", "()" + PBOOLEAN_SIGNATURE, null, null); - cv_shouldRefreshFetchGroup.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_shouldRefreshFetchGroup.visitFieldInsn(Opcodes.valueInt("GETFIELD"), classDetails.getClassName(), "_persistence_shouldRefreshFetchGroup", PBOOLEAN_SIGNATURE); - cv_shouldRefreshFetchGroup.visitInsn(Opcodes.valueInt("IRETURN")); + MethodVisitor cv_shouldRefreshFetchGroup = cv.visitMethod(Opcodes.ACC_PUBLIC, "_persistence_shouldRefreshFetchGroup", "()" + PBOOLEAN_SIGNATURE, null, null); + cv_shouldRefreshFetchGroup.visitVarInsn(Opcodes.ALOAD, 0); + cv_shouldRefreshFetchGroup.visitFieldInsn(Opcodes.GETFIELD, classDetails.getClassName(), "_persistence_shouldRefreshFetchGroup", PBOOLEAN_SIGNATURE); + cv_shouldRefreshFetchGroup.visitInsn(Opcodes.IRETURN); cv_shouldRefreshFetchGroup.visitMaxs(0, 0); - MethodVisitor cv_setShouldRefreshFetchGroup = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "_persistence_setShouldRefreshFetchGroup", "(" + PBOOLEAN_SIGNATURE + ")V", null, null); - cv_setShouldRefreshFetchGroup.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_setShouldRefreshFetchGroup.visitVarInsn(Opcodes.valueInt("ILOAD"), 1); - cv_setShouldRefreshFetchGroup.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), classDetails.getClassName(), "_persistence_shouldRefreshFetchGroup", PBOOLEAN_SIGNATURE); - cv_setShouldRefreshFetchGroup.visitInsn(Opcodes.valueInt("RETURN")); + MethodVisitor cv_setShouldRefreshFetchGroup = cv.visitMethod(Opcodes.ACC_PUBLIC, "_persistence_setShouldRefreshFetchGroup", "(" + PBOOLEAN_SIGNATURE + ")V", null, null); + cv_setShouldRefreshFetchGroup.visitVarInsn(Opcodes.ALOAD, 0); + cv_setShouldRefreshFetchGroup.visitVarInsn(Opcodes.ILOAD, 1); + cv_setShouldRefreshFetchGroup.visitFieldInsn(Opcodes.PUTFIELD, classDetails.getClassName(), "_persistence_shouldRefreshFetchGroup", PBOOLEAN_SIGNATURE); + cv_setShouldRefreshFetchGroup.visitInsn(Opcodes.RETURN); cv_setShouldRefreshFetchGroup.visitMaxs(0, 0); - MethodVisitor cv_resetFetchGroup = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "_persistence_resetFetchGroup", "()V", null, null); - cv_resetFetchGroup.visitInsn(Opcodes.valueInt("RETURN")); + MethodVisitor cv_resetFetchGroup = cv.visitMethod(Opcodes.ACC_PUBLIC, "_persistence_resetFetchGroup", "()V", null, null); + cv_resetFetchGroup.visitInsn(Opcodes.RETURN); cv_resetFetchGroup.visitMaxs(0, 0); - MethodVisitor cv_isAttributeFetched = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "_persistence_isAttributeFetched", "(Ljava/lang/String;)Z", null, null); - cv_isAttributeFetched.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_isAttributeFetched.visitFieldInsn(Opcodes.valueInt("GETFIELD"), classDetails.getClassName(), "_persistence_fetchGroup", FETCHGROUP_SIGNATURE); + MethodVisitor cv_isAttributeFetched = cv.visitMethod(Opcodes.ACC_PUBLIC, "_persistence_isAttributeFetched", "(Ljava/lang/String;)Z", null, null); + cv_isAttributeFetched.visitVarInsn(Opcodes.ALOAD, 0); + cv_isAttributeFetched.visitFieldInsn(Opcodes.GETFIELD, classDetails.getClassName(), "_persistence_fetchGroup", FETCHGROUP_SIGNATURE); Label gotoTrue = ASMFactory.createLabel(); - cv_isAttributeFetched.visitJumpInsn(Opcodes.valueInt("IFNULL"), gotoTrue); - cv_isAttributeFetched.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_isAttributeFetched.visitFieldInsn(Opcodes.valueInt("GETFIELD"), classDetails.getClassName(), "_persistence_fetchGroup", FETCHGROUP_SIGNATURE); - cv_isAttributeFetched.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - cv_isAttributeFetched.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), FETCHGROUP_SHORT_SIGNATURE, "containsAttributeInternal", "(Ljava/lang/String;)Z", false); + cv_isAttributeFetched.visitJumpInsn(Opcodes.IFNULL, gotoTrue); + cv_isAttributeFetched.visitVarInsn(Opcodes.ALOAD, 0); + cv_isAttributeFetched.visitFieldInsn(Opcodes.GETFIELD, classDetails.getClassName(), "_persistence_fetchGroup", FETCHGROUP_SIGNATURE); + cv_isAttributeFetched.visitVarInsn(Opcodes.ALOAD, 1); + cv_isAttributeFetched.visitMethodInsn(Opcodes.INVOKEVIRTUAL, FETCHGROUP_SHORT_SIGNATURE, "containsAttributeInternal", "(Ljava/lang/String;)Z", false); Label gotoFalse = ASMFactory.createLabel(); - cv_isAttributeFetched.visitJumpInsn(Opcodes.valueInt("IFEQ"), gotoFalse); + cv_isAttributeFetched.visitJumpInsn(Opcodes.IFEQ, gotoFalse); cv_isAttributeFetched.visitLabel(gotoTrue); - cv_isAttributeFetched.visitInsn(Opcodes.valueInt("ICONST_1")); + cv_isAttributeFetched.visitInsn(Opcodes.ICONST_1); Label gotoReturn = ASMFactory.createLabel(); - cv_isAttributeFetched.visitJumpInsn(Opcodes.valueInt("GOTO"), gotoReturn); + cv_isAttributeFetched.visitJumpInsn(Opcodes.GOTO, gotoReturn); cv_isAttributeFetched.visitLabel(gotoFalse); - cv_isAttributeFetched.visitInsn(Opcodes.valueInt("ICONST_0")); + cv_isAttributeFetched.visitInsn(Opcodes.ICONST_0); cv_isAttributeFetched.visitLabel(gotoReturn); - cv_isAttributeFetched.visitInsn(Opcodes.valueInt("IRETURN")); + cv_isAttributeFetched.visitInsn(Opcodes.IRETURN); cv_isAttributeFetched.visitMaxs(0, 0); - MethodVisitor cv_checkFetched = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "_persistence_checkFetched", "(Ljava/lang/String;)V", null, null); - cv_checkFetched.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_checkFetched.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - cv_checkFetched.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), classDetails.getClassName(), "_persistence_isAttributeFetched", "(Ljava/lang/String;)Z", false); + MethodVisitor cv_checkFetched = cv.visitMethod(Opcodes.ACC_PUBLIC, "_persistence_checkFetched", "(Ljava/lang/String;)V", null, null); + cv_checkFetched.visitVarInsn(Opcodes.ALOAD, 0); + cv_checkFetched.visitVarInsn(Opcodes.ALOAD, 1); + cv_checkFetched.visitMethodInsn(Opcodes.INVOKEVIRTUAL, classDetails.getClassName(), "_persistence_isAttributeFetched", "(Ljava/lang/String;)Z", false); gotoReturn = ASMFactory.createLabel(); - cv_checkFetched.visitJumpInsn(Opcodes.valueInt("IFNE"), gotoReturn); - cv_checkFetched.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_checkFetched.visitTypeInsn(Opcodes.valueInt("CHECKCAST"), FETCHGROUP_TRACKER_SHORT_SIGNATURE); - cv_checkFetched.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - cv_checkFetched.visitMethodInsn(Opcodes.valueInt("INVOKESTATIC"), ENTITY_MANAGER_IMPL_SHORT_SIGNATURE, "processUnfetchedAttribute", "(" + FETCHGROUP_TRACKER_SIGNATURE + "Ljava/lang/String;)V", false); + cv_checkFetched.visitJumpInsn(Opcodes.IFNE, gotoReturn); + cv_checkFetched.visitVarInsn(Opcodes.ALOAD, 0); + cv_checkFetched.visitTypeInsn(Opcodes.CHECKCAST, FETCHGROUP_TRACKER_SHORT_SIGNATURE); + cv_checkFetched.visitVarInsn(Opcodes.ALOAD, 1); + cv_checkFetched.visitMethodInsn(Opcodes.INVOKESTATIC, ENTITY_MANAGER_IMPL_SHORT_SIGNATURE, "processUnfetchedAttribute", "(" + FETCHGROUP_TRACKER_SIGNATURE + "Ljava/lang/String;)V", false); cv_checkFetched.visitLabel(gotoReturn); - cv_checkFetched.visitInsn(Opcodes.valueInt("RETURN")); + cv_checkFetched.visitInsn(Opcodes.RETURN); cv_checkFetched.visitMaxs(0, 0); - MethodVisitor cv_checkFetchedForSet = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "_persistence_checkFetchedForSet", "(Ljava/lang/String;)V", null, null); - cv_checkFetchedForSet.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_checkFetchedForSet.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - cv_checkFetchedForSet.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), classDetails.getClassName(), "_persistence_isAttributeFetched", "(Ljava/lang/String;)Z", false); + MethodVisitor cv_checkFetchedForSet = cv.visitMethod(Opcodes.ACC_PUBLIC, "_persistence_checkFetchedForSet", "(Ljava/lang/String;)V", null, null); + cv_checkFetchedForSet.visitVarInsn(Opcodes.ALOAD, 0); + cv_checkFetchedForSet.visitVarInsn(Opcodes.ALOAD, 1); + cv_checkFetchedForSet.visitMethodInsn(Opcodes.INVOKEVIRTUAL, classDetails.getClassName(), "_persistence_isAttributeFetched", "(Ljava/lang/String;)Z", false); gotoReturn = ASMFactory.createLabel(); - cv_checkFetchedForSet.visitJumpInsn(Opcodes.valueInt("IFNE"), gotoReturn); - cv_checkFetchedForSet.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - cv_checkFetchedForSet.visitTypeInsn(Opcodes.valueInt("CHECKCAST"), FETCHGROUP_TRACKER_SHORT_SIGNATURE); - cv_checkFetchedForSet.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - cv_checkFetchedForSet.visitMethodInsn(Opcodes.valueInt("INVOKESTATIC"), ENTITY_MANAGER_IMPL_SHORT_SIGNATURE, "processUnfetchedAttributeForSet", "(" + FETCHGROUP_TRACKER_SIGNATURE + "Ljava/lang/String;)V", false); + cv_checkFetchedForSet.visitJumpInsn(Opcodes.IFNE, gotoReturn); + cv_checkFetchedForSet.visitVarInsn(Opcodes.ALOAD, 0); + cv_checkFetchedForSet.visitTypeInsn(Opcodes.CHECKCAST, FETCHGROUP_TRACKER_SHORT_SIGNATURE); + cv_checkFetchedForSet.visitVarInsn(Opcodes.ALOAD, 1); + cv_checkFetchedForSet.visitMethodInsn(Opcodes.INVOKESTATIC, ENTITY_MANAGER_IMPL_SHORT_SIGNATURE, "processUnfetchedAttributeForSet", "(" + FETCHGROUP_TRACKER_SIGNATURE + "Ljava/lang/String;)V", false); cv_checkFetchedForSet.visitLabel(gotoReturn); - cv_checkFetchedForSet.visitInsn(Opcodes.valueInt("RETURN")); + cv_checkFetchedForSet.visitInsn(Opcodes.RETURN); cv_checkFetchedForSet.visitMaxs(0, 0); } diff --git a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/weaving/ComputeClassWriter.java b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/weaving/ComputeClassWriter.java index 97f14c9fb3a..14d435c8f54 100644 --- a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/weaving/ComputeClassWriter.java +++ b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/weaving/ComputeClassWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2015 -2011 INRIA, France Telecom * * Redistribution and use in source and binary forms, with or without @@ -33,8 +33,7 @@ package org.eclipse.persistence.internal.jpa.weaving; -import java.io.IOException; -import java.io.InputStream; + import org.eclipse.persistence.asm.ASMFactory; import org.eclipse.persistence.asm.AnnotationVisitor; @@ -42,13 +41,17 @@ import org.eclipse.persistence.asm.ClassWriter; import org.eclipse.persistence.asm.Opcodes; +import java.io.IOException; +import java.io.InputStream; + /** * A ClassWriter that computes the common super class of two classes without * actually loading them with a ClassLoader. * * @author Eric Bruneton */ -class ComputeClassWriter extends ClassWriter { +class +ComputeClassWriter extends ClassWriter { private ClassLoader l = null;//getClass().getClassLoader(); @@ -64,14 +67,14 @@ public String getCommonSuperClass(final String type1, final String type2) try { ClassReader info1 = typeInfo(type1); ClassReader info2 = typeInfo(type2); - if ((info1.getAccess() & Opcodes.valueInt("ACC_INTERFACE")) != 0) { + if ((info1.getAccess() & Opcodes.ACC_INTERFACE) != 0) { if (typeImplements(type2, info2, type1)) { return type1; } else { return "java/lang/Object"; } } - if ((info2.getAccess() & Opcodes.valueInt("ACC_INTERFACE")) != 0) { + if ((info2.getAccess() & Opcodes.ACC_INTERFACE) != 0) { if (typeImplements(type1, info1, type2)) { return type2; } else { diff --git a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/weaving/MethodWeaver.java b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/weaving/MethodWeaver.java index a8596c473ac..bce1a7588aa 100644 --- a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/weaving/MethodWeaver.java +++ b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/weaving/MethodWeaver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -58,7 +58,7 @@ public MethodWeaver(ClassWeaver tcw, String methodName, String methodDescriptor, @Override public void visitInsn (final int opcode) { weaveBeginningOfMethodIfRequired(); - if (opcode == Opcodes.valueInt("RETURN")) { + if (opcode == Opcodes.RETURN) { weaveEndOfMethodIfRequired(); } super.visitInsnSuper(opcode); @@ -104,8 +104,8 @@ public void visitMethodInsn (final int opcode, final String owner, final String this.tcw.classDetails.isInSuperclassHierarchy(owner) && this.tcw.classDetails.isInMetadataHierarchy(descClassName) && (this.tcw.classDetails.getNameOfSuperclassImplementingCloneMethod() == null)) { super.visitMethodInsnSuper(opcode, owner, name, desc, intf); - super.visitTypeInsnSuper(Opcodes.valueInt("CHECKCAST"), this.tcw.classDetails.getClassName()); - super.visitMethodInsnSuper(Opcodes.valueInt("INVOKEVIRTUAL"), this.tcw.classDetails.getClassName(), "_persistence_post_clone", "()Ljava/lang/Object;", false); + super.visitTypeInsnSuper(Opcodes.CHECKCAST, this.tcw.classDetails.getClassName()); + super.visitMethodInsnSuper(Opcodes.INVOKEVIRTUAL, this.tcw.classDetails.getClassName(), "_persistence_post_clone", "()Ljava/lang/Object;", false); } else { super.visitMethodInsnSuper(opcode, owner, name, desc, intf); } @@ -210,15 +210,15 @@ public void weaveAttributesIfRequired(int opcode, String owner, String name, Str super.visitFieldInsnSuper(opcode, owner, name, desc); return; } - if (opcode == Opcodes.valueInt("GETFIELD")) { + if (opcode == Opcodes.GETFIELD) { if (attributeDetails.weaveValueHolders() || tcw.classDetails.shouldWeaveFetchGroups()) { - methodVisitor.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), tcw.classDetails.getClassName(), ClassWeaver.PERSISTENCE_GET + name, "()" + attributeDetails.getReferenceClassType().getDescriptor(), false); + methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, tcw.classDetails.getClassName(), ClassWeaver.PERSISTENCE_GET + name, "()" + attributeDetails.getReferenceClassType().getDescriptor(), false); } else { super.visitFieldInsnSuper(opcode, owner, name, desc); } - } else if (opcode == Opcodes.valueInt("PUTFIELD")) { + } else if (opcode == Opcodes.PUTFIELD) { if ((attributeDetails.weaveValueHolders()) || (tcw.classDetails.shouldWeaveChangeTracking()) || (tcw.classDetails.shouldWeaveFetchGroups())) { - methodVisitor.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), tcw.classDetails.getClassName(), ClassWeaver.PERSISTENCE_SET + name, "(" + attributeDetails.getReferenceClassType().getDescriptor() + ")V", false); + methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, tcw.classDetails.getClassName(), ClassWeaver.PERSISTENCE_SET + name, "(" + attributeDetails.getReferenceClassType().getDescriptor() + ")V", false); } else { super.visitFieldInsnSuper(opcode, owner, name, desc); } @@ -332,51 +332,51 @@ public void weaveBeginningOfMethodIfRequired() { } if (isVirtual || (isGetMethod && !attributeDetails.hasField())) { if (tcw.classDetails.shouldWeaveFetchGroups()) { - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); if (isVirtual){ - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 1); } else { methodVisitor.visitLdcInsn(attributeName); } // _persistence_checkFetched("attributeName"); - methodVisitor.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), tcw.classDetails.getClassName(), "_persistence_checkFetched", "(Ljava/lang/String;)V", false); + methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, tcw.classDetails.getClassName(), "_persistence_checkFetched", "(Ljava/lang/String;)V", false); } if (!isVirtual && attributeDetails.weaveValueHolders()) { // _persistence_initialize_attributeName_vh(); - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - methodVisitor.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), tcw.classDetails.getClassName(), "_persistence_initialize_" + attributeName + ClassWeaver.PERSISTENCE_FIELDNAME_POSTFIX, "()V", false); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); + methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, tcw.classDetails.getClassName(), "_persistence_initialize_" + attributeName + ClassWeaver.PERSISTENCE_FIELDNAME_POSTFIX, "()V", false); // if (!_persistence_attributeName_vh.isInstantiated()) { - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - methodVisitor.visitFieldInsn(Opcodes.valueInt("GETFIELD"), tcw.classDetails.getClassName(), ClassWeaver.PERSISTENCE_FIELDNAME_PREFIX + attributeName + ClassWeaver.PERSISTENCE_FIELDNAME_POSTFIX, ClassWeaver.VHI_SIGNATURE); - methodVisitor.visitMethodInsn(Opcodes.valueInt("INVOKEINTERFACE"), ClassWeaver.VHI_SHORT_SIGNATURE, "isInstantiated", "()Z", true); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); + methodVisitor.visitFieldInsn(Opcodes.GETFIELD, tcw.classDetails.getClassName(), ClassWeaver.PERSISTENCE_FIELDNAME_PREFIX + attributeName + ClassWeaver.PERSISTENCE_FIELDNAME_POSTFIX, ClassWeaver.VHI_SIGNATURE); + methodVisitor.visitMethodInsn(Opcodes.INVOKEINTERFACE, ClassWeaver.VHI_SHORT_SIGNATURE, "isInstantiated", "()Z", true); Label l0 = ASMFactory.createLabel(); - methodVisitor.visitJumpInsn(Opcodes.valueInt("IFNE"), l0); + methodVisitor.visitJumpInsn(Opcodes.IFNE, l0); // Need to disable change tracking when the set method is called to avoid thinking the attribute changed. if (tcw.classDetails.shouldWeaveChangeTracking()) { // PropertyChangeListener temp_persistence_listener = _persistence_listener; - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - methodVisitor.visitFieldInsn(Opcodes.valueInt("GETFIELD"), tcw.classDetails.getClassName(), "_persistence_listener", ClassWeaver.PCL_SIGNATURE); - methodVisitor.visitVarInsn(Opcodes.valueInt("ASTORE"), 4); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); + methodVisitor.visitFieldInsn(Opcodes.GETFIELD, tcw.classDetails.getClassName(), "_persistence_listener", ClassWeaver.PCL_SIGNATURE); + methodVisitor.visitVarInsn(Opcodes.ASTORE, 4); // _persistence_listener = null; - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - methodVisitor.visitInsn(Opcodes.valueInt("ACONST_NULL")); - methodVisitor.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), tcw.classDetails.getClassName(), "_persistence_listener", ClassWeaver.PCL_SIGNATURE); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); + methodVisitor.visitInsn(Opcodes.ACONST_NULL); + methodVisitor.visitFieldInsn(Opcodes.PUTFIELD, tcw.classDetails.getClassName(), "_persistence_listener", ClassWeaver.PCL_SIGNATURE); } // setAttributeName((AttributeType)_persistence_attributeName_vh.getValue()); - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - methodVisitor.visitFieldInsn(Opcodes.valueInt("GETFIELD"), tcw.classDetails.getClassName(), ClassWeaver.PERSISTENCE_FIELDNAME_PREFIX + attributeName + ClassWeaver.PERSISTENCE_FIELDNAME_POSTFIX, ClassWeaver.VHI_SIGNATURE); - methodVisitor.visitMethodInsn(Opcodes.valueInt("INVOKEINTERFACE"), ClassWeaver.VHI_SHORT_SIGNATURE, "getValue", "()Ljava/lang/Object;", true); - methodVisitor.visitTypeInsn(Opcodes.valueInt("CHECKCAST"), referenceClassName.replace('.','/')); - methodVisitor.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), tcw.classDetails.getClassName(), setterMethodName, "(" + referenceClassType.getDescriptor() + ")V", false); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); + methodVisitor.visitFieldInsn(Opcodes.GETFIELD, tcw.classDetails.getClassName(), ClassWeaver.PERSISTENCE_FIELDNAME_PREFIX + attributeName + ClassWeaver.PERSISTENCE_FIELDNAME_POSTFIX, ClassWeaver.VHI_SIGNATURE); + methodVisitor.visitMethodInsn(Opcodes.INVOKEINTERFACE, ClassWeaver.VHI_SHORT_SIGNATURE, "getValue", "()Ljava/lang/Object;", true); + methodVisitor.visitTypeInsn(Opcodes.CHECKCAST, referenceClassName.replace('.','/')); + methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, tcw.classDetails.getClassName(), setterMethodName, "(" + referenceClassType.getDescriptor() + ")V", false); if (tcw.classDetails.shouldWeaveChangeTracking()) { // _persistence_listener = temp_persistence_listener; - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), 4); - methodVisitor.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), tcw.classDetails.getClassName(), "_persistence_listener", ClassWeaver.PCL_SIGNATURE); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 4); + methodVisitor.visitFieldInsn(Opcodes.PUTFIELD, tcw.classDetails.getClassName(), "_persistence_listener", ClassWeaver.PCL_SIGNATURE); } // } methodVisitor.visitLabel(l0); @@ -412,16 +412,16 @@ public void weaveBeginningOfMethodIfRequired() { // if this is a primitive, get the wrapper class String wrapper = ClassWeaver.wrapperFor(referenceClassType.getSort()); - methodVisitor.visitInsn(Opcodes.valueInt("ACONST_NULL")); + methodVisitor.visitInsn(Opcodes.ACONST_NULL); if (wrapper != null){ - methodVisitor.visitVarInsn(Opcodes.valueInt("ASTORE"), valueStorageLocation + 1); + methodVisitor.visitVarInsn(Opcodes.ASTORE, valueStorageLocation + 1); } else { - methodVisitor.visitVarInsn(Opcodes.valueInt("ASTORE"), valueStorageLocation); + methodVisitor.visitVarInsn(Opcodes.ASTORE, valueStorageLocation); } - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - methodVisitor.visitFieldInsn(Opcodes.valueInt("GETFIELD"), tcw.classDetails.getClassName(), "_persistence_listener", "Ljava/beans/PropertyChangeListener;"); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); + methodVisitor.visitFieldInsn(Opcodes.GETFIELD, tcw.classDetails.getClassName(), "_persistence_listener", "Ljava/beans/PropertyChangeListener;"); Label l0 = ASMFactory.createLabel(); - methodVisitor.visitJumpInsn(Opcodes.valueInt("IFNULL"), l0); + methodVisitor.visitJumpInsn(Opcodes.IFNULL, l0); /** * The code below constructs the following code @@ -432,65 +432,65 @@ public void weaveBeginningOfMethodIfRequired() { */ // 1st part of invoking constructor for primitives to wrap them if (wrapper != null) { - methodVisitor.visitTypeInsn(Opcodes.valueInt("NEW"), wrapper); - methodVisitor.visitInsn(Opcodes.valueInt("DUP")); + methodVisitor.visitTypeInsn(Opcodes.NEW, wrapper); + methodVisitor.visitInsn(Opcodes.DUP); } // Call the getter // getAttribute() - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); String getterArgument = ""; String getterReturn = referenceClassType.getDescriptor(); if (isVirtual){ getterArgument = ClassWeaver.STRING_SIGNATURE; getterReturn = ClassWeaver.OBJECT_SIGNATURE; - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 1); } - methodVisitor.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), tcw.classDetails.getClassName(), getterMethodName, "(" + getterArgument + ")" + getterReturn, false); + methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, tcw.classDetails.getClassName(), getterMethodName, "(" + getterArgument + ")" + getterReturn, false); if (wrapper != null){ // 2nd part of using constructor. - methodVisitor.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), wrapper, "", "(" + referenceClassType.getDescriptor() + ")V", false); - methodVisitor.visitVarInsn(Opcodes.valueInt("ASTORE"), valueStorageLocation + 1); + methodVisitor.visitMethodInsn(Opcodes.INVOKESPECIAL, wrapper, "", "(" + referenceClassType.getDescriptor() + ")V", false); + methodVisitor.visitVarInsn(Opcodes.ASTORE, valueStorageLocation + 1); } else { // store the result - methodVisitor.visitVarInsn(Opcodes.valueInt("ASTORE"), valueStorageLocation); + methodVisitor.visitVarInsn(Opcodes.ASTORE, valueStorageLocation); } Label l1 = ASMFactory.createLabel(); - methodVisitor.visitJumpInsn(Opcodes.valueInt("GOTO"), l1); + methodVisitor.visitJumpInsn(Opcodes.GOTO, l1); methodVisitor.visitLabel(l0); - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); if (isVirtual){ - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 1); } else { methodVisitor.visitLdcInsn(attributeName); } - methodVisitor.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), tcw.classDetails.getClassName(), "_persistence_checkFetchedForSet", "(Ljava/lang/String;)V", false); + methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, tcw.classDetails.getClassName(), "_persistence_checkFetchedForSet", "(Ljava/lang/String;)V", false); methodVisitor.visitLabel(l1); - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); if (isVirtual){ - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 1); } else { methodVisitor.visitLdcInsn(attributeName); } if (wrapper != null) { - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), valueStorageLocation + 1); - methodVisitor.visitTypeInsn(Opcodes.valueInt("NEW"), wrapper); - methodVisitor.visitInsn(Opcodes.valueInt("DUP")); + methodVisitor.visitVarInsn(Opcodes.ALOAD, valueStorageLocation + 1); + methodVisitor.visitTypeInsn(Opcodes.NEW, wrapper); + methodVisitor.visitInsn(Opcodes.DUP); } else { - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), valueStorageLocation); + methodVisitor.visitVarInsn(Opcodes.ALOAD, valueStorageLocation); } // get an appropriate load opcode for the type - int opcode = referenceClassType.getOpcode(Opcodes.valueInt("ILOAD")); + int opcode = referenceClassType.getOpcode(Opcodes.ILOAD); methodVisitor.visitVarInsn(opcode, valueHoldingLocation); if (wrapper != null){ - methodVisitor.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), wrapper, "", "(" + referenceClassType.getDescriptor() + ")V", false); + methodVisitor.visitMethodInsn(Opcodes.INVOKESPECIAL, wrapper, "", "(" + referenceClassType.getDescriptor() + ")V", false); } - methodVisitor.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), tcw.classDetails.getClassName(), "_persistence_propertyChange", "(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V", false); + methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, tcw.classDetails.getClassName(), "_persistence_propertyChange", "(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V", false); } else { // tcw.classDetails.shouldWeaveFetchGroups() /** @@ -505,63 +505,62 @@ public void weaveBeginningOfMethodIfRequired() { // 1st part of invoking constructor for primitives to wrap them if (wrapper != null) { - methodVisitor.visitTypeInsn(Opcodes.valueInt("NEW"), wrapper); - methodVisitor.visitInsn(Opcodes.valueInt("DUP")); - } + methodVisitor.visitTypeInsn(Opcodes.NEW, wrapper); + methodVisitor.visitInsn(Opcodes.DUP); } // Call the getter // getAttribute() - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); String getterArgument = ""; String getterReturn = referenceClassType.getDescriptor(); if (isVirtual){ getterArgument = ClassWeaver.STRING_SIGNATURE; getterReturn = ClassWeaver.OBJECT_SIGNATURE; - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 1); } - methodVisitor.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), tcw.classDetails.getClassName(), getterMethodName, "(" + getterArgument + ")" + getterReturn, false); + methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, tcw.classDetails.getClassName(), getterMethodName, "(" + getterArgument + ")" + getterReturn, false); if (wrapper != null){ // 2nd part of using constructor. - methodVisitor.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), wrapper, "", "(" + attributeDetails.getReferenceClassType().getDescriptor() + ")V", false); - methodVisitor.visitVarInsn(Opcodes.valueInt("ASTORE"), valueStorageLocation + 1); + methodVisitor.visitMethodInsn(Opcodes.INVOKESPECIAL, wrapper, "", "(" + attributeDetails.getReferenceClassType().getDescriptor() + ")V", false); + methodVisitor.visitVarInsn(Opcodes.ASTORE, valueStorageLocation + 1); } else { // store the result - methodVisitor.visitVarInsn(Opcodes.valueInt("ASTORE"), valueStorageLocation); + methodVisitor.visitVarInsn(Opcodes.ASTORE, valueStorageLocation); } // makes use of the value stored in weaveBeginningOfMethodIfRequired to call property change method // _persistence_propertyChange("attributeName", oldAttribute, argument); - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); if (isVirtual){ - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 1); } else { methodVisitor.visitLdcInsn(attributeName); } if (wrapper != null) { - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), valueStorageLocation + 1); - methodVisitor.visitTypeInsn(Opcodes.valueInt("NEW"), wrapper); - methodVisitor.visitInsn(Opcodes.valueInt("DUP")); + methodVisitor.visitVarInsn(Opcodes.ALOAD, valueStorageLocation + 1); + methodVisitor.visitTypeInsn(Opcodes.NEW, wrapper); + methodVisitor.visitInsn(Opcodes.DUP); } else { - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), valueStorageLocation); + methodVisitor.visitVarInsn(Opcodes.ALOAD, valueStorageLocation); } - int opcode = referenceClassType.getOpcode(Opcodes.valueInt("ILOAD")); + int opcode = referenceClassType.getOpcode(Opcodes.ILOAD); methodVisitor.visitVarInsn(opcode, valueHoldingLocation); if (wrapper != null) { - methodVisitor.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), wrapper, "", "(" + referenceClassType.getDescriptor() + ")V", false); + methodVisitor.visitMethodInsn(Opcodes.INVOKESPECIAL, wrapper, "", "(" + referenceClassType.getDescriptor() + ")V", false); } - methodVisitor.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), tcw.classDetails.getClassName(), "_persistence_propertyChange", "(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V", false); + methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, tcw.classDetails.getClassName(), "_persistence_propertyChange", "(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V", false); } } else { // !tcw.classDetails.shouldWeaveChangeTracking() if(tcw.classDetails.shouldWeaveFetchGroups()) { - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); if (isVirtual){ - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 1); } else { methodVisitor.visitLdcInsn(attributeName); } // _persistence_checkFetchedForSet("variableName"); - methodVisitor.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), tcw.classDetails.getClassName(), "_persistence_checkFetchedForSet", "(Ljava/lang/String;)V", false); + methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, tcw.classDetails.getClassName(), "_persistence_checkFetchedForSet", "(Ljava/lang/String;)V", false); } } } @@ -588,20 +587,20 @@ public void weaveEndOfMethodIfRequired() { boolean isSetMethod = (attributeDetails != null) && this.methodDescriptor.equals(attributeDetails.getSetterMethodSignature()); if (isSetMethod && !attributeDetails.hasField()) { if (attributeDetails.weaveValueHolders()) { - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - methodVisitor.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), tcw.classDetails.getClassName(), "_persistence_initialize_" + attributeDetails.getAttributeName() + ClassWeaver.PERSISTENCE_FIELDNAME_POSTFIX, "()V", false); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); + methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, tcw.classDetails.getClassName(), "_persistence_initialize_" + attributeDetails.getAttributeName() + ClassWeaver.PERSISTENCE_FIELDNAME_POSTFIX, "()V", false); //_persistence_attributeName_vh.setValue(argument); - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - methodVisitor.visitFieldInsn(Opcodes.valueInt("GETFIELD"), tcw.classDetails.getClassName(), ClassWeaver.PERSISTENCE_FIELDNAME_PREFIX + attributeDetails.getAttributeName() + ClassWeaver.PERSISTENCE_FIELDNAME_POSTFIX, ClassWeaver.VHI_SIGNATURE); - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - methodVisitor.visitMethodInsn(Opcodes.valueInt("INVOKEINTERFACE"), ClassWeaver.VHI_SHORT_SIGNATURE, "setValue", "(Ljava/lang/Object;)V", true); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); + methodVisitor.visitFieldInsn(Opcodes.GETFIELD, tcw.classDetails.getClassName(), ClassWeaver.PERSISTENCE_FIELDNAME_PREFIX + attributeDetails.getAttributeName() + ClassWeaver.PERSISTENCE_FIELDNAME_POSTFIX, ClassWeaver.VHI_SIGNATURE); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 1); + methodVisitor.visitMethodInsn(Opcodes.INVOKEINTERFACE, ClassWeaver.VHI_SHORT_SIGNATURE, "setValue", "(Ljava/lang/Object;)V", true); // _persistence_attributeName_vh.setIsCoordinatedWithProperty(true); - methodVisitor.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - methodVisitor.visitFieldInsn(Opcodes.valueInt("GETFIELD"), tcw.classDetails.getClassName(), ClassWeaver.PERSISTENCE_FIELDNAME_PREFIX + attributeDetails.getAttributeName() + ClassWeaver.PERSISTENCE_FIELDNAME_POSTFIX, ClassWeaver.VHI_SIGNATURE); - methodVisitor.visitInsn(Opcodes.valueInt("ICONST_1")); - methodVisitor.visitMethodInsn(Opcodes.valueInt("INVOKEINTERFACE"), ClassWeaver.VHI_SHORT_SIGNATURE, "setIsCoordinatedWithProperty", "(Z)V", true); + methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); + methodVisitor.visitFieldInsn(Opcodes.GETFIELD, tcw.classDetails.getClassName(), ClassWeaver.PERSISTENCE_FIELDNAME_PREFIX + attributeDetails.getAttributeName() + ClassWeaver.PERSISTENCE_FIELDNAME_POSTFIX, ClassWeaver.VHI_SIGNATURE); + methodVisitor.visitInsn(Opcodes.ICONST_1); + methodVisitor.visitMethodInsn(Opcodes.INVOKEINTERFACE, ClassWeaver.VHI_SHORT_SIGNATURE, "setIsCoordinatedWithProperty", "(Z)V", true); } } } diff --git a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/weaving/PersistenceWeaver.java b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/weaving/PersistenceWeaver.java index c874aa0ed8f..2daa35ae74f 100644 --- a/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/weaving/PersistenceWeaver.java +++ b/jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/weaving/PersistenceWeaver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -17,24 +17,24 @@ package org.eclipse.persistence.internal.jpa.weaving; // J2SE imports -import java.security.ProtectionDomain; -import java.util.Map; import jakarta.persistence.spi.ClassTransformer; import jakarta.persistence.spi.TransformerException; - -import org.eclipse.persistence.config.SystemProperties; -import org.eclipse.persistence.internal.helper.Helper; import org.eclipse.persistence.asm.ASMFactory; import org.eclipse.persistence.asm.ClassReader; import org.eclipse.persistence.asm.ClassVisitor; import org.eclipse.persistence.asm.ClassWriter; import org.eclipse.persistence.asm.EclipseLinkClassReader; -import org.eclipse.persistence.internal.localization.ExceptionLocalization; +import org.eclipse.persistence.asm.internal.Util; +import org.eclipse.persistence.config.SystemProperties; +import org.eclipse.persistence.internal.helper.Helper; import org.eclipse.persistence.internal.security.PrivilegedAccessHelper; import org.eclipse.persistence.logging.AbstractSessionLog; import org.eclipse.persistence.logging.SessionLog; -import org.eclipse.persistence.logging.SessionLogEntry; + +import java.security.ProtectionDomain; +import java.util.HashMap; +import java.util.Map; /** * INTERNAL: @@ -46,6 +46,7 @@ public class PersistenceWeaver implements ClassTransformer { /** Class name in JVM '/' format to {@link ClassDetails} map. */ protected Map classDetailsMap; + private final static Map ASM_CLASSWRITER_MAP = new HashMap<>(); /** * INTERNAL: @@ -74,7 +75,9 @@ public void clear() { public Map getClassDetailsMap() { return classDetailsMap; } - + private static int valueInt(String fieldName) { + return ((int) Util.getFieldValue(ASM_CLASSWRITER_MAP, fieldName, Integer.TYPE)); + } /** * INTERNAL: * Perform dynamic byte code weaving of class. @@ -126,9 +129,9 @@ public byte[] transform(final ClassLoader loader, final String className, PrivilegedAccessHelper.getSystemProperty(SystemProperties.WEAVING_REFLECTIVE_INTROSPECTION); ClassWriter classWriter = null; if (reflectiveIntrospectionProperty != null) { - classWriter = ASMFactory.createClassWriter(ClassWriter.valueInt("COMPUTE_FRAMES")); + classWriter = ASMFactory.createClassWriter(valueInt("COMPUTE_FRAMES")); } else { - classWriter = new ComputeClassWriter(loader, ClassWriter.valueInt("COMPUTE_FRAMES")); + classWriter = new ComputeClassWriter(loader,valueInt("COMPUTE_FRAMES")); classWriter.setCustomClassWriterInImpl(classWriter); } final ClassWeaver classWeaver = new ClassWeaver(classWriter, classDetails); diff --git a/jpa/org.eclipse.persistence.jpars.server/src/main/java/org/eclipse/persistence/internal/jpa/rs/weaving/CollectionProxyClassWriter.java b/jpa/org.eclipse.persistence.jpars.server/src/main/java/org/eclipse/persistence/internal/jpa/rs/weaving/CollectionProxyClassWriter.java index 5036c048c6d..d83c2673265 100644 --- a/jpa/org.eclipse.persistence.jpars.server/src/main/java/org/eclipse/persistence/internal/jpa/rs/weaving/CollectionProxyClassWriter.java +++ b/jpa/org.eclipse.persistence.jpars.server/src/main/java/org/eclipse/persistence/internal/jpa/rs/weaving/CollectionProxyClassWriter.java @@ -106,10 +106,10 @@ public byte[] writeClass(DynamicClassLoader loader, String className) { MethodVisitor mv; // public class Proxy extends SuperType implements CollectionProxy - cw.visit(Opcodes.valueInt("ACC_PUBLIC") + Opcodes.valueInt("ACC_SUPER"), getASMClassName(), null, getASMParentClassName(), new String[]{INTERFACE}); + cw.visit(Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, getASMClassName(), null, getASMParentClassName(), new String[]{INTERFACE}); // private List links; - final FieldVisitor fv = cw.visitField(Opcodes.valueInt("ACC_PRIVATE"), "links", "Ljava/util/List;", "Ljava/util/List;", null); + final FieldVisitor fv = cw.visitField(Opcodes.ACC_PRIVATE, "links", "Ljava/util/List;", "Ljava/util/List;", null); fv.visitEnd(); // public CollectionProxy(Collection c) { @@ -117,24 +117,24 @@ public byte[] writeClass(DynamicClassLoader loader, String className) { // this.addAll(c); // } { - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "", "(Ljava/util/Collection;)V", null, null); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "", "(Ljava/util/Collection;)V", null, null); mv.visitCode(); Label l0 = ASMFactory.createLabel(); mv.visitLabel(l0); mv.visitLineNumber(15, l0); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), getASMParentClassName(), "", "()V", false); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, getASMParentClassName(), "", "()V", false); Label l1 = ASMFactory.createLabel(); mv.visitLabel(l1); mv.visitLineNumber(16, l1); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - mv.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), getASMClassName(), "addAll", "(Ljava/util/Collection;)Z", false); - mv.visitInsn(Opcodes.valueInt("POP")); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitVarInsn(Opcodes.ALOAD, 1); + mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, getASMClassName(), "addAll", "(Ljava/util/Collection;)Z", false); + mv.visitInsn(Opcodes.POP); Label l2 = ASMFactory.createLabel(); mv.visitLabel(l2); mv.visitLineNumber(17, l2); - mv.visitInsn(Opcodes.valueInt("RETURN")); + mv.visitInsn(Opcodes.RETURN); Label l3 = ASMFactory.createLabel(); mv.visitLabel(l3); mv.visitLocalVariable("this", "L" + getASMClassName() + ";", null, l0, l3, 0); @@ -148,14 +148,14 @@ public byte[] writeClass(DynamicClassLoader loader, String className) { // return links; // } { - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "getLinks", "()Ljava/util/List;", "()Ljava/util/List;", null); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "getLinks", "()Ljava/util/List;", "()Ljava/util/List;", null); mv.visitCode(); Label l0 = ASMFactory.createLabel(); mv.visitLabel(l0); mv.visitLineNumber(21, l0); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitFieldInsn(Opcodes.valueInt("GETFIELD"), getASMClassName(), "links", "Ljava/util/List;"); - mv.visitInsn(Opcodes.valueInt("ARETURN")); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitFieldInsn(Opcodes.GETFIELD, getASMClassName(), "links", "Ljava/util/List;"); + mv.visitInsn(Opcodes.ARETURN); Label l1 = ASMFactory.createLabel(); mv.visitLabel(l1); mv.visitLocalVariable("this", "L" + getASMClassName() + ";", null, l0, l1, 0); @@ -168,18 +168,18 @@ public byte[] writeClass(DynamicClassLoader loader, String className) { // this.links = links; // } { - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "setLinks", "(Ljava/util/List;)V", "(Ljava/util/List;)V", null); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "setLinks", "(Ljava/util/List;)V", "(Ljava/util/List;)V", null); mv.visitCode(); Label l0 = ASMFactory.createLabel(); mv.visitLabel(l0); mv.visitLineNumber(26, l0); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - mv.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), getASMClassName(), "links", "Ljava/util/List;"); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitVarInsn(Opcodes.ALOAD, 1); + mv.visitFieldInsn(Opcodes.PUTFIELD, getASMClassName(), "links", "Ljava/util/List;"); Label l1 = ASMFactory.createLabel(); mv.visitLabel(l1); mv.visitLineNumber(27, l1); - mv.visitInsn(Opcodes.valueInt("RETURN")); + mv.visitInsn(Opcodes.RETURN); Label l2 = ASMFactory.createLabel(); mv.visitLabel(l2); mv.visitLocalVariable("this", "L" + getASMClassName()+ ";", null, l0, l2, 0); diff --git a/jpa/org.eclipse.persistence.jpars.server/src/main/java/org/eclipse/persistence/internal/jpa/rs/weaving/RestAdapterClassWriter.java b/jpa/org.eclipse.persistence.jpars.server/src/main/java/org/eclipse/persistence/internal/jpa/rs/weaving/RestAdapterClassWriter.java index 30f9e337dd6..cc4714b1c5a 100644 --- a/jpa/org.eclipse.persistence.jpars.server/src/main/java/org/eclipse/persistence/internal/jpa/rs/weaving/RestAdapterClassWriter.java +++ b/jpa/org.eclipse.persistence.jpars.server/src/main/java/org/eclipse/persistence/internal/jpa/rs/weaving/RestAdapterClassWriter.java @@ -63,23 +63,23 @@ public byte[] writeClass(DynamicClassLoader loader, String className) ClassWriter cw = new EclipseLinkASMClassWriter(0); - cw.visit(Opcodes.valueInt("ACC_PUBLIC") + Opcodes.valueInt("ACC_SUPER"), getASMClassName(), "L" + REFERENCE_ADAPTER_SHORT_SIGNATURE + ";", REFERENCE_ADAPTER_SHORT_SIGNATURE, null); + cw.visit(Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, getASMClassName(), "L" + REFERENCE_ADAPTER_SHORT_SIGNATURE + ";", REFERENCE_ADAPTER_SHORT_SIGNATURE, null); - MethodVisitor mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "", "()V", null, null); + MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "", "()V", null, null); mv.visitCode(); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), REFERENCE_ADAPTER_SHORT_SIGNATURE, "", "()V", false); - mv.visitInsn(Opcodes.valueInt("RETURN")); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, REFERENCE_ADAPTER_SHORT_SIGNATURE, "", "()V", false); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(1, 1); mv.visitEnd(); - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "", "(Ljava/lang/String;Lorg/eclipse/persistence/jpa/rs/PersistenceContext;)V", null, null); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "", "(Ljava/lang/String;Lorg/eclipse/persistence/jpa/rs/PersistenceContext;)V", null, null); mv.visitCode(); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 2); - mv.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), REFERENCE_ADAPTER_SHORT_SIGNATURE, "", "(Ljava/lang/String;Lorg/eclipse/persistence/jpa/rs/PersistenceContext;)V", false); - mv.visitInsn(Opcodes.valueInt("RETURN")); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitVarInsn(Opcodes.ALOAD, 1); + mv.visitVarInsn(Opcodes.ALOAD, 2); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, REFERENCE_ADAPTER_SHORT_SIGNATURE, "", "(Ljava/lang/String;Lorg/eclipse/persistence/jpa/rs/PersistenceContext;)V", false); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(3, 3); mv.visitEnd(); diff --git a/jpa/org.eclipse.persistence.jpars.server/src/main/java/org/eclipse/persistence/internal/jpa/rs/weaving/RestCollectionAdapterClassWriter.java b/jpa/org.eclipse.persistence.jpars.server/src/main/java/org/eclipse/persistence/internal/jpa/rs/weaving/RestCollectionAdapterClassWriter.java index 16c97881e26..1cb68cde329 100644 --- a/jpa/org.eclipse.persistence.jpars.server/src/main/java/org/eclipse/persistence/internal/jpa/rs/weaving/RestCollectionAdapterClassWriter.java +++ b/jpa/org.eclipse.persistence.jpars.server/src/main/java/org/eclipse/persistence/internal/jpa/rs/weaving/RestCollectionAdapterClassWriter.java @@ -84,24 +84,24 @@ public byte[] writeClass(DynamicClassLoader loader, String className) throws Cla // Class signature final ClassWriter cw = new EclipseLinkASMClassWriter(0); - cw.visit(Opcodes.valueInt("ACC_PUBLIC") + Opcodes.valueInt("ACC_SUPER"), getASMClassName(), "L" + REFERENCE_ADAPTER_SHORT_SIGNATURE + ";", REFERENCE_ADAPTER_SHORT_SIGNATURE, null); + cw.visit(Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, getASMClassName(), "L" + REFERENCE_ADAPTER_SHORT_SIGNATURE + ";", REFERENCE_ADAPTER_SHORT_SIGNATURE, null); // Default constructor - MethodVisitor mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "", "()V", null, null); + MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "", "()V", null, null); mv.visitCode(); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), REFERENCE_ADAPTER_SHORT_SIGNATURE, "", "()V", false); - mv.visitInsn(Opcodes.valueInt("RETURN")); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, REFERENCE_ADAPTER_SHORT_SIGNATURE, "", "()V", false); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(1, 1); mv.visitEnd(); // Another constructor - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "", "(Lorg/eclipse/persistence/jpa/rs/PersistenceContext;)V", null, null); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "", "(Lorg/eclipse/persistence/jpa/rs/PersistenceContext;)V", null, null); mv.visitCode(); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - mv.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), REFERENCE_ADAPTER_SHORT_SIGNATURE, "", "(Lorg/eclipse/persistence/jpa/rs/PersistenceContext;)V", false); - mv.visitInsn(Opcodes.valueInt("RETURN")); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitVarInsn(Opcodes.ALOAD, 1); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, REFERENCE_ADAPTER_SHORT_SIGNATURE, "", "(Lorg/eclipse/persistence/jpa/rs/PersistenceContext;)V", false); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(2, 2); mv.visitEnd(); diff --git a/jpa/org.eclipse.persistence.jpars.server/src/main/java/org/eclipse/persistence/internal/jpa/rs/weaving/RestDynamicClassWriter.java b/jpa/org.eclipse.persistence.jpars.server/src/main/java/org/eclipse/persistence/internal/jpa/rs/weaving/RestDynamicClassWriter.java index 1b56536af3e..3e3da2b2679 100644 --- a/jpa/org.eclipse.persistence.jpars.server/src/main/java/org/eclipse/persistence/internal/jpa/rs/weaving/RestDynamicClassWriter.java +++ b/jpa/org.eclipse.persistence.jpars.server/src/main/java/org/eclipse/persistence/internal/jpa/rs/weaving/RestDynamicClassWriter.java @@ -43,13 +43,13 @@ public RestDynamicClassWriter(MetadataDynamicClassWriter w) { protected void addFields(ClassWriter cw, String parentClassType) { super.addFields(cw, parentClassType); // protected transient List _persistence_relationshipInfo; - FieldVisitor fv = cw.visitField(Opcodes.valueInt("ACC_PROTECTED") | Opcodes.valueInt("ACC_TRANSIENT"), PERSISTENCE_FIELDNAME_PREFIX + "relationshipInfo", LIST_RELATIONSHIP_INFO_SIGNATURE, LIST_RELATIONSHIP_INFO_GENERIC_SIGNATURE, null); + FieldVisitor fv = cw.visitField(Opcodes.ACC_PROTECTED | Opcodes.ACC_TRANSIENT, PERSISTENCE_FIELDNAME_PREFIX + "relationshipInfo", LIST_RELATIONSHIP_INFO_SIGNATURE, LIST_RELATIONSHIP_INFO_GENERIC_SIGNATURE, null); fv.visitEnd(); // protected transient Link _persistence_href; - fv = cw.visitField(Opcodes.valueInt("ACC_PROTECTED") | Opcodes.valueInt("ACC_TRANSIENT"), PERSISTENCE_FIELDNAME_PREFIX + "href", LINK_SIGNATURE, null, null); + fv = cw.visitField(Opcodes.ACC_PROTECTED | Opcodes.ACC_TRANSIENT, PERSISTENCE_FIELDNAME_PREFIX + "href", LINK_SIGNATURE, null, null); fv.visitEnd(); // protected transient ItemLinks _persistence_links; - fv = cw.visitField(Opcodes.valueInt("ACC_PROTECTED") | Opcodes.valueInt("ACC_TRANSIENT"), PERSISTENCE_FIELDNAME_PREFIX + "links", ITEM_LINKS_SIGNATURE, null, null); + fv = cw.visitField(Opcodes.ACC_PROTECTED | Opcodes.ACC_TRANSIENT, PERSISTENCE_FIELDNAME_PREFIX + "links", ITEM_LINKS_SIGNATURE, null, null); fv.visitEnd(); } @@ -61,63 +61,63 @@ protected void addMethods(ClassWriter cw, String parentClassType) { // public List _persistence_getRelationships() { // return this._persistence_relationshipInfo; // } - MethodVisitor mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), PERSISTENCE_FIELDNAME_PREFIX + "getRelationships", "()" + LIST_RELATIONSHIP_INFO_SIGNATURE, "()" + LIST_RELATIONSHIP_INFO_GENERIC_SIGNATURE, null); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitFieldInsn(Opcodes.valueInt("GETFIELD"), clsName, PERSISTENCE_FIELDNAME_PREFIX + "relationshipInfo", LIST_RELATIONSHIP_INFO_SIGNATURE); - mv.visitInsn(Opcodes.valueInt("ARETURN")); + MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, PERSISTENCE_FIELDNAME_PREFIX + "getRelationships", "()" + LIST_RELATIONSHIP_INFO_SIGNATURE, "()" + LIST_RELATIONSHIP_INFO_GENERIC_SIGNATURE, null); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitFieldInsn(Opcodes.GETFIELD, clsName, PERSISTENCE_FIELDNAME_PREFIX + "relationshipInfo", LIST_RELATIONSHIP_INFO_SIGNATURE); + mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(1, 1); mv.visitEnd(); // public void _persistence_setRelationships(List paramList) { // this._persistence_relationshipInfo = paramList; // } - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), PERSISTENCE_FIELDNAME_PREFIX + "setRelationships", "(" + LIST_RELATIONSHIP_INFO_SIGNATURE + ")V", "(" + LIST_RELATIONSHIP_INFO_GENERIC_SIGNATURE + ")V", null); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - mv.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), clsName, PERSISTENCE_FIELDNAME_PREFIX + "relationshipInfo", LIST_RELATIONSHIP_INFO_SIGNATURE); - mv.visitInsn(Opcodes.valueInt("RETURN")); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC, PERSISTENCE_FIELDNAME_PREFIX + "setRelationships", "(" + LIST_RELATIONSHIP_INFO_SIGNATURE + ")V", "(" + LIST_RELATIONSHIP_INFO_GENERIC_SIGNATURE + ")V", null); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitVarInsn(Opcodes.ALOAD, 1); + mv.visitFieldInsn(Opcodes.PUTFIELD, clsName, PERSISTENCE_FIELDNAME_PREFIX + "relationshipInfo", LIST_RELATIONSHIP_INFO_SIGNATURE); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(2, 2); mv.visitEnd(); // public Link _persistence_getHref() { // return this._persistence_href; // } - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), PERSISTENCE_FIELDNAME_PREFIX + "getHref", "()" + LINK_SIGNATURE, null, null); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitFieldInsn(Opcodes.valueInt("GETFIELD"), clsName, PERSISTENCE_FIELDNAME_PREFIX + "href", LINK_SIGNATURE); - mv.visitInsn(Opcodes.valueInt("ARETURN")); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC, PERSISTENCE_FIELDNAME_PREFIX + "getHref", "()" + LINK_SIGNATURE, null, null); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitFieldInsn(Opcodes.GETFIELD, clsName, PERSISTENCE_FIELDNAME_PREFIX + "href", LINK_SIGNATURE); + mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(1, 1); mv.visitEnd(); // public void _persistence_setHref(Link paramLink) // this._persistence_href = paramLink; // } - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), PERSISTENCE_FIELDNAME_PREFIX + "setHref", "(" + LINK_SIGNATURE + ")V", null, null); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - mv.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), clsName, PERSISTENCE_FIELDNAME_PREFIX + "href", LINK_SIGNATURE); - mv.visitInsn(Opcodes.valueInt("RETURN")); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC, PERSISTENCE_FIELDNAME_PREFIX + "setHref", "(" + LINK_SIGNATURE + ")V", null, null); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitVarInsn(Opcodes.ALOAD, 1); + mv.visitFieldInsn(Opcodes.PUTFIELD, clsName, PERSISTENCE_FIELDNAME_PREFIX + "href", LINK_SIGNATURE); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(2, 2); mv.visitEnd(); // public ItemLinks _persistence_getLinks() { // return this._persistence_links; // } - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), PERSISTENCE_FIELDNAME_PREFIX + "getLinks", "()" + ITEM_LINKS_SIGNATURE, null, null); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitFieldInsn(Opcodes.valueInt("GETFIELD"), clsName, PERSISTENCE_FIELDNAME_PREFIX + "links", ITEM_LINKS_SIGNATURE); - mv.visitInsn(Opcodes.valueInt("ARETURN")); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC, PERSISTENCE_FIELDNAME_PREFIX + "getLinks", "()" + ITEM_LINKS_SIGNATURE, null, null); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitFieldInsn(Opcodes.GETFIELD, clsName, PERSISTENCE_FIELDNAME_PREFIX + "links", ITEM_LINKS_SIGNATURE); + mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(1, 1); mv.visitEnd(); // public void _persistence_setLinks(ItemLinks paramItemLinks) { // this._persistence_links = paramItemLinks; // } - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), PERSISTENCE_FIELDNAME_PREFIX + "setLinks", "(" + ITEM_LINKS_SIGNATURE + ")V", null, null); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - mv.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), clsName, PERSISTENCE_FIELDNAME_PREFIX + "links", ITEM_LINKS_SIGNATURE); - mv.visitInsn(Opcodes.valueInt("RETURN")); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC, PERSISTENCE_FIELDNAME_PREFIX + "setLinks", "(" + ITEM_LINKS_SIGNATURE + ")V", null, null); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitVarInsn(Opcodes.ALOAD, 1); + mv.visitFieldInsn(Opcodes.PUTFIELD, clsName, PERSISTENCE_FIELDNAME_PREFIX + "links", ITEM_LINKS_SIGNATURE); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(2, 2); mv.visitEnd(); } diff --git a/jpa/org.eclipse.persistence.jpars.server/src/main/java/org/eclipse/persistence/internal/jpa/rs/weaving/RestReferenceAdapterV2ClassWriter.java b/jpa/org.eclipse.persistence.jpars.server/src/main/java/org/eclipse/persistence/internal/jpa/rs/weaving/RestReferenceAdapterV2ClassWriter.java index 4cb0d0150a6..cafc82f6a1b 100644 --- a/jpa/org.eclipse.persistence.jpars.server/src/main/java/org/eclipse/persistence/internal/jpa/rs/weaving/RestReferenceAdapterV2ClassWriter.java +++ b/jpa/org.eclipse.persistence.jpars.server/src/main/java/org/eclipse/persistence/internal/jpa/rs/weaving/RestReferenceAdapterV2ClassWriter.java @@ -82,24 +82,24 @@ public byte[] writeClass(DynamicClassLoader loader, String className) throws ClassNotFoundException { final ClassWriter cw = new EclipseLinkASMClassWriter(0); - cw.visit(Opcodes.valueInt("ACC_PUBLIC") + Opcodes.valueInt("ACC_SUPER"), getASMClassName(), "L" + REFERENCE_ADAPTER_SHORT_SIGNATURE + ";", REFERENCE_ADAPTER_SHORT_SIGNATURE, null); + cw.visit(Opcodes.ACC_PUBLIC+ Opcodes.ACC_SUPER, getASMClassName(), "L" + REFERENCE_ADAPTER_SHORT_SIGNATURE + ";", REFERENCE_ADAPTER_SHORT_SIGNATURE, null); // Default constructor - MethodVisitor mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "", "()V", null, null); + MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "", "()V", null, null); mv.visitCode(); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), REFERENCE_ADAPTER_SHORT_SIGNATURE, "", "()V", false); - mv.visitInsn(Opcodes.valueInt("RETURN")); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, REFERENCE_ADAPTER_SHORT_SIGNATURE, "", "()V", false); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(1, 1); mv.visitEnd(); // Another constructor - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "", "(Lorg/eclipse/persistence/jpa/rs/PersistenceContext;)V", null, null); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "", "(Lorg/eclipse/persistence/jpa/rs/PersistenceContext;)V", null, null); mv.visitCode(); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - mv.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), REFERENCE_ADAPTER_SHORT_SIGNATURE, "", "(Lorg/eclipse/persistence/jpa/rs/PersistenceContext;)V", false); - mv.visitInsn(Opcodes.valueInt("RETURN")); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitVarInsn(Opcodes.ALOAD, 1); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, REFERENCE_ADAPTER_SHORT_SIGNATURE, "", "(Lorg/eclipse/persistence/jpa/rs/PersistenceContext;)V", false); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(2, 2); mv.visitEnd(); diff --git a/moxy/org.eclipse.persistence.moxy/src/main/java/org/eclipse/persistence/jaxb/compiler/AnnotationsProcessor.java b/moxy/org.eclipse.persistence.moxy/src/main/java/org/eclipse/persistence/jaxb/compiler/AnnotationsProcessor.java index 146e0245f1b..a330e73d462 100644 --- a/moxy/org.eclipse.persistence.moxy/src/main/java/org/eclipse/persistence/jaxb/compiler/AnnotationsProcessor.java +++ b/moxy/org.eclipse.persistence.moxy/src/main/java/org/eclipse/persistence/jaxb/compiler/AnnotationsProcessor.java @@ -14,81 +14,17 @@ // Oracle - initial API and implementation from Oracle TopLink package org.eclipse.persistence.jaxb.compiler; -import java.awt.Image; -import java.beans.Introspector; -import java.lang.annotation.Annotation; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.lang.reflect.ParameterizedType; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import jakarta.validation.constraints.DecimalMax; -import jakarta.validation.constraints.DecimalMin; import jakarta.validation.constraints.Digits; -import jakarta.validation.constraints.Max; -import jakarta.validation.constraints.Min; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Pattern; -import jakarta.validation.constraints.Size; +import jakarta.validation.constraints.*; import jakarta.xml.bind.Marshaller; import jakarta.xml.bind.Unmarshaller; -import jakarta.xml.bind.annotation.XmlAccessorOrder; -import jakarta.xml.bind.annotation.XmlAccessorType; -import jakarta.xml.bind.annotation.XmlAnyAttribute; -import jakarta.xml.bind.annotation.XmlAnyElement; -import jakarta.xml.bind.annotation.XmlAttachmentRef; -import jakarta.xml.bind.annotation.XmlAttribute; -import jakarta.xml.bind.annotation.XmlElement; -import jakarta.xml.bind.annotation.XmlElementDecl; -import jakarta.xml.bind.annotation.XmlElementRef; -import jakarta.xml.bind.annotation.XmlElementRefs; -import jakarta.xml.bind.annotation.XmlElementWrapper; -import jakarta.xml.bind.annotation.XmlElements; -import jakarta.xml.bind.annotation.XmlEnum; -import jakarta.xml.bind.annotation.XmlEnumValue; -import jakarta.xml.bind.annotation.XmlID; -import jakarta.xml.bind.annotation.XmlIDREF; -import jakarta.xml.bind.annotation.XmlInlineBinaryData; -import jakarta.xml.bind.annotation.XmlList; -import jakarta.xml.bind.annotation.XmlMimeType; -import jakarta.xml.bind.annotation.XmlMixed; -import jakarta.xml.bind.annotation.XmlNs; -import jakarta.xml.bind.annotation.XmlNsForm; -import jakarta.xml.bind.annotation.XmlRegistry; -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlSchema; -import jakarta.xml.bind.annotation.XmlSchemaType; -import jakarta.xml.bind.annotation.XmlSchemaTypes; -import jakarta.xml.bind.annotation.XmlTransient; -import jakarta.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.*; import jakarta.xml.bind.annotation.XmlType.DEFAULT; -import jakarta.xml.bind.annotation.XmlValue; import jakarta.xml.bind.annotation.adapters.XmlAdapter; import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapters; -import javax.xml.namespace.QName; -import javax.xml.transform.Source; - -import org.eclipse.persistence.asm.AnnotationVisitor; -import org.eclipse.persistence.asm.ASMFactory; -import org.eclipse.persistence.asm.ClassWriter; -import org.eclipse.persistence.asm.EclipseLinkASMClassWriter; -import org.eclipse.persistence.asm.FieldVisitor; import org.eclipse.persistence.asm.Label; -import org.eclipse.persistence.asm.MethodVisitor; -import org.eclipse.persistence.asm.Opcodes; -import org.eclipse.persistence.asm.Type; +import org.eclipse.persistence.asm.*; import org.eclipse.persistence.exceptions.ConversionException; import org.eclipse.persistence.exceptions.JAXBException; import org.eclipse.persistence.internal.core.helper.CoreClassConstants; @@ -96,11 +32,7 @@ import org.eclipse.persistence.internal.helper.ConversionManager; import org.eclipse.persistence.internal.jaxb.AccessorFactoryWrapper; import org.eclipse.persistence.internal.jaxb.JaxbClassLoader; -import org.eclipse.persistence.internal.jaxb.many.ArrayValue; -import org.eclipse.persistence.internal.jaxb.many.CollectionValue; -import org.eclipse.persistence.internal.jaxb.many.ManyValue; -import org.eclipse.persistence.internal.jaxb.many.MultiDimensionalArrayValue; -import org.eclipse.persistence.internal.jaxb.many.MultiDimensionalCollectionValue; +import org.eclipse.persistence.internal.jaxb.many.*; import org.eclipse.persistence.internal.oxm.Constants; import org.eclipse.persistence.internal.oxm.Namespace; import org.eclipse.persistence.internal.oxm.XMLConversionManager; @@ -109,23 +41,8 @@ import org.eclipse.persistence.internal.security.PrivilegedAccessHelper; import org.eclipse.persistence.jaxb.MOXySystemProperties; import org.eclipse.persistence.jaxb.TypeMappingInfo; -import org.eclipse.persistence.jaxb.compiler.facets.DecimalMaxFacet; -import org.eclipse.persistence.jaxb.compiler.facets.DecimalMinFacet; -import org.eclipse.persistence.jaxb.compiler.facets.DigitsFacet; -import org.eclipse.persistence.jaxb.compiler.facets.MaxFacet; -import org.eclipse.persistence.jaxb.compiler.facets.MinFacet; -import org.eclipse.persistence.jaxb.compiler.facets.PatternFacet; -import org.eclipse.persistence.jaxb.compiler.facets.PatternListFacet; -import org.eclipse.persistence.jaxb.compiler.facets.SizeFacet; -import org.eclipse.persistence.jaxb.javamodel.AnnotationProxy; -import org.eclipse.persistence.jaxb.javamodel.Helper; -import org.eclipse.persistence.jaxb.javamodel.JavaAnnotation; -import org.eclipse.persistence.jaxb.javamodel.JavaClass; -import org.eclipse.persistence.jaxb.javamodel.JavaConstructor; -import org.eclipse.persistence.jaxb.javamodel.JavaField; -import org.eclipse.persistence.jaxb.javamodel.JavaHasAnnotations; -import org.eclipse.persistence.jaxb.javamodel.JavaMethod; -import org.eclipse.persistence.jaxb.javamodel.JavaPackage; +import org.eclipse.persistence.jaxb.compiler.facets.*; +import org.eclipse.persistence.jaxb.javamodel.*; import org.eclipse.persistence.jaxb.javamodel.reflection.JavaFieldImpl; import org.eclipse.persistence.jaxb.xmlmodel.XmlAccessOrder; import org.eclipse.persistence.jaxb.xmlmodel.XmlAccessType; @@ -137,38 +54,20 @@ import org.eclipse.persistence.oxm.NamespaceResolver; import org.eclipse.persistence.oxm.XMLField; import org.eclipse.persistence.oxm.XMLNameTransformer; -import org.eclipse.persistence.oxm.annotations.XmlAccessMethods; -import org.eclipse.persistence.oxm.annotations.XmlCDATA; -import org.eclipse.persistence.oxm.annotations.XmlClassExtractor; -import org.eclipse.persistence.oxm.annotations.XmlCustomizer; -import org.eclipse.persistence.oxm.annotations.XmlDiscriminatorNode; -import org.eclipse.persistence.oxm.annotations.XmlDiscriminatorValue; -import org.eclipse.persistence.oxm.annotations.XmlElementNillable; -import org.eclipse.persistence.oxm.annotations.XmlElementsJoinNodes; -import org.eclipse.persistence.oxm.annotations.XmlIDExtension; -import org.eclipse.persistence.oxm.annotations.XmlInverseReference; -import org.eclipse.persistence.oxm.annotations.XmlIsSetNullPolicy; -import org.eclipse.persistence.oxm.annotations.XmlJoinNode; -import org.eclipse.persistence.oxm.annotations.XmlJoinNodes; -import org.eclipse.persistence.oxm.annotations.XmlKey; -import org.eclipse.persistence.oxm.annotations.XmlLocation; -import org.eclipse.persistence.oxm.annotations.XmlNameTransformer; -import org.eclipse.persistence.oxm.annotations.XmlNamedAttributeNode; -import org.eclipse.persistence.oxm.annotations.XmlNamedObjectGraph; -import org.eclipse.persistence.oxm.annotations.XmlNamedObjectGraphs; -import org.eclipse.persistence.oxm.annotations.XmlNamedSubgraph; -import org.eclipse.persistence.oxm.annotations.XmlNullPolicy; -import org.eclipse.persistence.oxm.annotations.XmlParameter; -import org.eclipse.persistence.oxm.annotations.XmlPath; -import org.eclipse.persistence.oxm.annotations.XmlPaths; -import org.eclipse.persistence.oxm.annotations.XmlProperties; -import org.eclipse.persistence.oxm.annotations.XmlProperty; -import org.eclipse.persistence.oxm.annotations.XmlReadOnly; -import org.eclipse.persistence.oxm.annotations.XmlValueExtension; -import org.eclipse.persistence.oxm.annotations.XmlVariableNode; -import org.eclipse.persistence.oxm.annotations.XmlVirtualAccessMethods; -import org.eclipse.persistence.oxm.annotations.XmlWriteOnly; -import org.eclipse.persistence.oxm.annotations.XmlWriteTransformers; +import org.eclipse.persistence.oxm.annotations.*; + +import javax.xml.namespace.QName; +import javax.xml.transform.Source; +import java.awt.*; +import java.beans.Introspector; +import java.lang.annotation.Annotation; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.lang.reflect.ParameterizedType; +import java.util.List; +import java.util.*; +import java.util.Map.Entry; /** * INTERNAL: @@ -4217,11 +4116,11 @@ private Class generateWrapperForMapClass(JavaClass mapClass, JavaClass keyCla ClassWriter cw = new EclipseLinkASMClassWriter(); String sig = "Lorg/eclipse/persistence/internal/jaxb/many/MapValue;>;"; - cw.visit(Opcodes.valueInt("ACC_PUBLIC") + Opcodes.valueInt("ACC_SUPER"), qualifiedInternalClassName, sig, "org/eclipse/persistence/internal/jaxb/many/MapValue", null); + cw.visit(Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, qualifiedInternalClassName, sig, "org/eclipse/persistence/internal/jaxb/many/MapValue", null); // Write Field: @... public Map entry String fieldSig = L + mapType.getInternalName() + ";"; - FieldVisitor fv = cw.visitField(Opcodes.valueInt("ACC_PUBLIC"), "entry", L + mapType.getInternalName() + SEMI_COLON, fieldSig, null); + FieldVisitor fv = cw.visitField(Opcodes.ACC_PUBLIC, "entry", L + mapType.getInternalName() + SEMI_COLON, fieldSig, null); fv.visitAnnotation(Type.getDescriptor(XmlElement.class), true); if (typeMappingInfo != null) { Annotation[] annotations = typeMappingInfo.getAnnotations(); @@ -4251,25 +4150,25 @@ private Class generateWrapperForMapClass(JavaClass mapClass, JavaClass keyCla } fv.visitEnd(); - MethodVisitor mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "", "()V", null, null); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), "org/eclipse/persistence/internal/jaxb/many/MapValue", "", "()V", false); - mv.visitInsn(Opcodes.valueInt("RETURN")); + MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "", "()V", null, null); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "org/eclipse/persistence/internal/jaxb/many/MapValue", "", "()V", false); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(1, 1); mv.visitEnd(); // Write: @XmlTransient public void setItem(???) String methodSig = "(L" + mapType.getInternalName() + ";)V"; - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "setItem", "(L" + mapType.getInternalName() + ";)V", methodSig, null); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "setItem", "(L" + mapType.getInternalName() + ";)V", methodSig, null); // TODO: Verify that we really want to put @XmlTranient on setItem // method mv.visitAnnotation("Ljakarta/xml/bind/annotation/XmlTransient;", true); Label l0 = ASMFactory.createLabel(); mv.visitLabel(l0); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - mv.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), qualifiedInternalClassName, "entry", L + mapType.getInternalName() + SEMI_COLON); - mv.visitInsn(Opcodes.valueInt("RETURN")); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitVarInsn(Opcodes.ALOAD, 1); + mv.visitFieldInsn(Opcodes.PUTFIELD, qualifiedInternalClassName, "entry", L + mapType.getInternalName() + SEMI_COLON); + mv.visitInsn(Opcodes.RETURN); Label l1 = ASMFactory.createLabel(); mv.visitLabel(l1); @@ -4282,27 +4181,27 @@ private Class generateWrapperForMapClass(JavaClass mapClass, JavaClass keyCla // Write @XmlTransient public ??? getItem() methodSig = "()L" + mapType.getInternalName() + ";"; - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "getItem", "()L" + mapType.getInternalName() + SEMI_COLON, methodSig, null); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "getItem", "()L" + mapType.getInternalName() + SEMI_COLON, methodSig, null); mv.visitAnnotation("Ljakarta/xml/bind/annotation/XmlTransient;", true); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitFieldInsn(Opcodes.valueInt("GETFIELD"), qualifiedInternalClassName, "entry", L + mapType.getInternalName() + SEMI_COLON); - mv.visitInsn(Opcodes.valueInt("ARETURN")); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitFieldInsn(Opcodes.GETFIELD, qualifiedInternalClassName, "entry", L + mapType.getInternalName() + SEMI_COLON); + mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(1, 1); mv.visitEnd(); - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC") + Opcodes.valueInt("ACC_BRIDGE") + Opcodes.valueInt("ACC_SYNTHETIC"), "getItem", "()Ljava/lang/Object;", null, null); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), qualifiedInternalClassName, "getItem", "()L" + mapType.getInternalName() + SEMI_COLON, false); - mv.visitInsn(Opcodes.valueInt("ARETURN")); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_BRIDGE + Opcodes.ACC_SYNTHETIC, "getItem", "()Ljava/lang/Object;", null, null); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, qualifiedInternalClassName, "getItem", "()L" + mapType.getInternalName() + SEMI_COLON, false); + mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(1, 1); mv.visitEnd(); - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC") + Opcodes.valueInt("ACC_BRIDGE") + Opcodes.valueInt("ACC_SYNTHETIC"), "setItem", "(Ljava/lang/Object;)V", null, null); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - mv.visitTypeInsn(Opcodes.valueInt("CHECKCAST"), mapType.getInternalName()); - mv.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), qualifiedInternalClassName, "setItem", "(L" + mapType.getInternalName() + ";)V", false); - mv.visitInsn(Opcodes.valueInt("RETURN")); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_BRIDGE + Opcodes.ACC_SYNTHETIC, "setItem", "(Ljava/lang/Object;)V", null, null); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitVarInsn(Opcodes.ALOAD, 1); + mv.visitTypeInsn(Opcodes.CHECKCAST, mapType.getInternalName()); + mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, qualifiedInternalClassName, "setItem", "(L" + mapType.getInternalName() + ";)V", false); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(2, 2); mv.visitEnd(); @@ -4528,9 +4427,9 @@ private void generateManyValueClass(ClassWriter cw, TypeMappingInfo typeMappingI String componentClassNameSeparatedBySlash = getObjectType(componentType).getQualifiedName().replace(DOT_CHR, SLASH_CHR); String containerClassNameSeperatedBySlash = containerType.getQualifiedName().replace(DOT_CHR, SLASH_CHR); if("[B".equals(componentClassNameSeparatedBySlash)) { - cw.visit(Opcodes.valueInt("ACC_PUBLIC") + Opcodes.valueInt("ACC_SUPER"), classNameSeparatedBySlash, "L" + Type.getInternalName(superType) + "<" + componentClassNameSeparatedBySlash + ">;", Type.getInternalName(superType), null); + cw.visit(Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, classNameSeparatedBySlash, "L" + Type.getInternalName(superType) + "<" + componentClassNameSeparatedBySlash + ">;", Type.getInternalName(superType), null); } else { - cw.visit(Opcodes.valueInt("ACC_PUBLIC") + Opcodes.valueInt("ACC_SUPER"), classNameSeparatedBySlash, "L" + Type.getInternalName(superType) + ";", Type.getInternalName(superType), null); + cw.visit(Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, classNameSeparatedBySlash, "L" + Type.getInternalName(superType) + ";", Type.getInternalName(superType), null); } // Write @XmlType(namespace) @@ -4544,11 +4443,11 @@ private void generateManyValueClass(ClassWriter cw, TypeMappingInfo typeMappingI av.visitEnd(); // Public No-Arg Constructor - MethodVisitor mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "", "()V", null, null); + MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "", "()V", null, null); mv.visitCode(); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), Type.getInternalName(superType), "", "()V", false); - mv.visitInsn(Opcodes.valueInt("RETURN")); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, Type.getInternalName(superType), "", "()V", false); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(1, 1); mv.visitEnd(); @@ -4564,31 +4463,31 @@ private void generateManyValueClass(ClassWriter cw, TypeMappingInfo typeMappingI // adaptedValue.toArray(array); // return array; // } - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "getItem", "()Ljava/lang/Object;", null, null); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "getItem", "()Ljava/lang/Object;", null, null); mv.visitCode(); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitFieldInsn(Opcodes.valueInt("GETFIELD"), classNameSeparatedBySlash, "adaptedValue", "Ljava/util/Collection;"); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitFieldInsn(Opcodes.GETFIELD, classNameSeparatedBySlash, "adaptedValue", "Ljava/util/Collection;"); Label l0 = ASMFactory.createLabel();; - mv.visitJumpInsn(Opcodes.valueInt("IFNONNULL"), l0); - mv.visitInsn(Opcodes.valueInt("ACONST_NULL")); - mv.visitInsn(Opcodes.valueInt("ARETURN")); + mv.visitJumpInsn(Opcodes.IFNONNULL, l0); + mv.visitInsn(Opcodes.ACONST_NULL); + mv.visitInsn(Opcodes.ARETURN); mv.visitLabel(l0); - mv.visitFrame(Opcodes.valueInt("F_SAME"), 0, null, 0, null); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitFieldInsn(Opcodes.valueInt("GETFIELD"), classNameSeparatedBySlash, "adaptedValue", "Ljava/util/Collection;"); - mv.visitMethodInsn(Opcodes.valueInt("INVOKEINTERFACE"), "java/util/Collection", "size", "()I", true); - mv.visitVarInsn(Opcodes.valueInt("ISTORE"), 1); - mv.visitVarInsn(Opcodes.valueInt("ILOAD"), 1); - mv.visitTypeInsn(Opcodes.valueInt("ANEWARRAY"), componentClassNameSeparatedBySlash); - mv.visitVarInsn(Opcodes.valueInt("ASTORE"), 2); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitFieldInsn(Opcodes.valueInt("GETFIELD"), classNameSeparatedBySlash, "adaptedValue", "Ljava/util/Collection;"); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 2); - mv.visitMethodInsn(Opcodes.valueInt("INVOKEINTERFACE"), "java/util/Collection", "toArray", "([Ljava/lang/Object;)[Ljava/lang/Object;", true); - mv.visitInsn(Opcodes.valueInt("POP")); - - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 2); - mv.visitInsn(Opcodes.valueInt("ARETURN")); + mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitFieldInsn(Opcodes.GETFIELD, classNameSeparatedBySlash, "adaptedValue", "Ljava/util/Collection;"); + mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/Collection", "size", "()I", true); + mv.visitVarInsn(Opcodes.ISTORE, 1); + mv.visitVarInsn(Opcodes.ILOAD, 1); + mv.visitTypeInsn(Opcodes.ANEWARRAY, componentClassNameSeparatedBySlash); + mv.visitVarInsn(Opcodes.ASTORE, 2); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitFieldInsn(Opcodes.GETFIELD, classNameSeparatedBySlash, "adaptedValue", "Ljava/util/Collection;"); + mv.visitVarInsn(Opcodes.ALOAD, 2); + mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/Collection", "toArray", "([Ljava/lang/Object;)[Ljava/lang/Object;", true); + mv.visitInsn(Opcodes.POP); + + mv.visitVarInsn(Opcodes.ALOAD, 2); + mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(2, 3); mv.visitEnd(); @@ -4598,16 +4497,16 @@ private void generateManyValueClass(ClassWriter cw, TypeMappingInfo typeMappingI // Float[] floatArray = (Float[])array; // adaptedValue = (Collection) Arrays.asList(floatArray); //} - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "setItem", "(Ljava/lang/Object;)V", null, null); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "setItem", "(Ljava/lang/Object;)V", null, null); mv.visitCode(); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - mv.visitTypeInsn(Opcodes.valueInt("CHECKCAST"), "[L"+componentClassNameSeparatedBySlash+";"); - mv.visitVarInsn(Opcodes.valueInt("ASTORE"), 2); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 2); - mv.visitMethodInsn(Opcodes.valueInt("INVOKESTATIC"), "java/util/Arrays", "asList", "([Ljava/lang/Object;)Ljava/util/List;", false); - mv.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), classNameSeparatedBySlash, "adaptedValue", "Ljava/util/Collection;"); - mv.visitInsn(Opcodes.valueInt("RETURN")); + mv.visitVarInsn(Opcodes.ALOAD, 1); + mv.visitTypeInsn(Opcodes.CHECKCAST, "[L"+componentClassNameSeparatedBySlash+";"); + mv.visitVarInsn(Opcodes.ASTORE, 2); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitVarInsn(Opcodes.ALOAD, 2); + mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/util/Arrays", "asList", "([Ljava/lang/Object;)Ljava/util/List;", false); + mv.visitFieldInsn(Opcodes.PUTFIELD, classNameSeparatedBySlash, "adaptedValue", "Ljava/util/Collection;"); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(2, 3); mv.visitEnd(); } @@ -4623,9 +4522,9 @@ private void generateManyValueClass(ClassWriter cw, TypeMappingInfo typeMappingI // return super.getAdaptedValue(); // } if("[B".equals(componentClassNameSeparatedBySlash)) { - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "getAdaptedValue", "()Ljava/util/Collection;", "()Ljava/util/Collection<" + componentClassNameSeparatedBySlash + ">;", null); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "getAdaptedValue", "()Ljava/util/Collection;", "()Ljava/util/Collection<" + componentClassNameSeparatedBySlash + ">;", null); } else { - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "getAdaptedValue", "()Ljava/util/Collection;", "()Ljava/util/Collection;", null); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "getAdaptedValue", "()Ljava/util/Collection;", "()Ljava/util/Collection;", null); } // Copy annotations boolean hasXmlList = false; @@ -4668,31 +4567,31 @@ private void generateManyValueClass(ClassWriter cw, TypeMappingInfo typeMappingI } mv.visitCode(); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), Type.getInternalName(superType), "getAdaptedValue", "()Ljava/util/Collection;", false); - mv.visitInsn(Opcodes.valueInt("ARETURN")); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, Type.getInternalName(superType), "getAdaptedValue", "()Ljava/util/Collection;", false); + mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(1, 1); mv.visitEnd(); // public void setAdaptedValue(Collection adaptedValue) { // super.setAdaptedValue(adaptedValue); // } - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "setAdaptedValue", "(Ljava/util/Collection;)V", "(Ljava/util/Collection;)V", null); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "setAdaptedValue", "(Ljava/util/Collection;)V", "(Ljava/util/Collection;)V", null); mv.visitCode(); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - mv.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), Type.getInternalName(superType), "setAdaptedValue", "(Ljava/util/Collection;)V", false); - mv.visitInsn(Opcodes.valueInt("RETURN")); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitVarInsn(Opcodes.ALOAD, 1); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, Type.getInternalName(superType), "setAdaptedValue", "(Ljava/util/Collection;)V", false); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(2, 2); mv.visitEnd(); // public Class containerClass() { // return CONTAINER_TYPE.class; // } - mv = cw.visitMethod(Opcodes.valueInt("ACC_PROTECTED"), "containerClass", "()Ljava/lang/Class;", "()Ljava/lang/Class<*>;", null); + mv = cw.visitMethod(Opcodes.ACC_PROTECTED, "containerClass", "()Ljava/lang/Class;", "()Ljava/lang/Class<*>;", null); mv.visitCode(); if(componentType.isPrimitive()) { - mv.visitFieldInsn(Opcodes.valueInt("GETSTATIC"), getObjectType(componentType).getQualifiedName().replace(DOT_CHR, SLASH_CHR), "TYPE", "Ljava/lang/Class;"); + mv.visitFieldInsn(Opcodes.GETSTATIC, getObjectType(componentType).getQualifiedName().replace(DOT_CHR, SLASH_CHR), "TYPE", "Ljava/lang/Class;"); } else { if(containerClassNameSeperatedBySlash.contains(";")) { mv.visitLdcInsn(Type.getType(containerClassNameSeperatedBySlash).unwrap()); @@ -4700,7 +4599,7 @@ private void generateManyValueClass(ClassWriter cw, TypeMappingInfo typeMappingI mv.visitLdcInsn(Type.getType("L" + containerClassNameSeperatedBySlash + ";").unwrap()); } } - mv.visitInsn(Opcodes.valueInt("ARETURN")); + mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(1, 1); mv.visitEnd(); } @@ -4718,10 +4617,10 @@ private void generateMultiDimensionalManyValueClass(ClassWriter cw, JavaClass co // return COMPONENT_TYPE.class; // } String componentClassNameSeparatedBySlash = componentType.getQualifiedName().replace(DOT_CHR, SLASH_CHR); - MethodVisitor mv = cw.visitMethod(Opcodes.valueInt("ACC_PROTECTED"), "componentClass", "()Ljava/lang/Class;", "()Ljava/lang/Class;", null); + MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PROTECTED, "componentClass", "()Ljava/lang/Class;", "()Ljava/lang/Class;", null); mv.visitCode(); mv.visitLdcInsn(Type.getType("L" + componentClassNameSeparatedBySlash + ";").unwrap()); - mv.visitInsn(Opcodes.valueInt("ARETURN")); + mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(1, 1); mv.visitEnd(); } diff --git a/moxy/org.eclipse.persistence.moxy/src/main/java/org/eclipse/persistence/jaxb/compiler/MappingsGenerator.java b/moxy/org.eclipse.persistence.moxy/src/main/java/org/eclipse/persistence/jaxb/compiler/MappingsGenerator.java index 86d4d66ba62..0d6440f7e0c 100644 --- a/moxy/org.eclipse.persistence.moxy/src/main/java/org/eclipse/persistence/jaxb/compiler/MappingsGenerator.java +++ b/moxy/org.eclipse.persistence.moxy/src/main/java/org/eclipse/persistence/jaxb/compiler/MappingsGenerator.java @@ -14,28 +14,6 @@ // Oracle - initial API and implementation from Oracle TopLink package org.eclipse.persistence.jaxb.compiler; -import java.awt.Image; -import java.beans.Introspector; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Deque; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.NavigableSet; -import java.util.Queue; -import java.util.Set; -import java.util.SortedSet; -import java.util.StringTokenizer; -import java.util.TreeSet; - -import javax.xml.namespace.QName; -import javax.xml.transform.Source; - import jakarta.xml.bind.JAXBElement; import jakarta.xml.bind.annotation.XmlAttribute; import jakarta.xml.bind.annotation.XmlMixed; @@ -43,12 +21,7 @@ import jakarta.xml.bind.annotation.XmlValue; import jakarta.xml.bind.annotation.adapters.CollapsedStringAdapter; import jakarta.xml.bind.annotation.adapters.NormalizedStringAdapter; - -import org.eclipse.persistence.asm.ClassWriter; -import org.eclipse.persistence.asm.EclipseLinkASMClassWriter; -import org.eclipse.persistence.asm.MethodVisitor; -import org.eclipse.persistence.asm.Opcodes; -import org.eclipse.persistence.asm.Type; +import org.eclipse.persistence.asm.*; import org.eclipse.persistence.config.DescriptorCustomizer; import org.eclipse.persistence.core.descriptors.CoreDescriptor; import org.eclipse.persistence.core.mappings.CoreMapping; @@ -65,17 +38,7 @@ import org.eclipse.persistence.internal.descriptors.MethodAttributeAccessor; import org.eclipse.persistence.internal.descriptors.VirtualAttributeAccessor; import org.eclipse.persistence.internal.helper.DatabaseField; -import org.eclipse.persistence.internal.jaxb.AccessorFactoryWrapper; -import org.eclipse.persistence.internal.jaxb.CustomAccessorAttributeAccessor; -import org.eclipse.persistence.internal.jaxb.DefaultElementConverter; -import org.eclipse.persistence.internal.jaxb.DomHandlerConverter; -import org.eclipse.persistence.internal.jaxb.JAXBElementConverter; -import org.eclipse.persistence.internal.jaxb.JAXBElementRootConverter; -import org.eclipse.persistence.internal.jaxb.JAXBSetMethodAttributeAccessor; -import org.eclipse.persistence.internal.jaxb.JaxbClassLoader; -import org.eclipse.persistence.internal.jaxb.MultiArgInstantiationPolicy; -import org.eclipse.persistence.internal.jaxb.WrappedValue; -import org.eclipse.persistence.internal.jaxb.XMLJavaTypeConverter; +import org.eclipse.persistence.internal.jaxb.*; import org.eclipse.persistence.internal.jaxb.many.JAXBArrayAttributeAccessor; import org.eclipse.persistence.internal.jaxb.many.ManyValue; import org.eclipse.persistence.internal.jaxb.many.MapValue; @@ -84,27 +47,7 @@ import org.eclipse.persistence.internal.oxm.Constants; import org.eclipse.persistence.internal.oxm.NamespaceResolver; import org.eclipse.persistence.internal.oxm.XMLConversionManager; -import org.eclipse.persistence.internal.oxm.mappings.AnyAttributeMapping; -import org.eclipse.persistence.internal.oxm.mappings.AnyCollectionMapping; -import org.eclipse.persistence.internal.oxm.mappings.AnyObjectMapping; -import org.eclipse.persistence.internal.oxm.mappings.BinaryDataCollectionMapping; -import org.eclipse.persistence.internal.oxm.mappings.BinaryDataMapping; -import org.eclipse.persistence.internal.oxm.mappings.ChoiceCollectionMapping; -import org.eclipse.persistence.internal.oxm.mappings.ChoiceObjectMapping; -import org.eclipse.persistence.internal.oxm.mappings.CollectionReferenceMapping; -import org.eclipse.persistence.internal.oxm.mappings.CompositeCollectionMapping; -import org.eclipse.persistence.internal.oxm.mappings.CompositeObjectMapping; -import org.eclipse.persistence.internal.oxm.mappings.Descriptor; -import org.eclipse.persistence.internal.oxm.mappings.DirectCollectionMapping; -import org.eclipse.persistence.internal.oxm.mappings.DirectMapping; -import org.eclipse.persistence.internal.oxm.mappings.Field; -import org.eclipse.persistence.internal.oxm.mappings.InverseReferenceMapping; -import org.eclipse.persistence.internal.oxm.mappings.Mapping; -import org.eclipse.persistence.internal.oxm.mappings.ObjectReferenceMapping; -import org.eclipse.persistence.internal.oxm.mappings.TransformationMapping; -import org.eclipse.persistence.internal.oxm.mappings.VariableXPathCollectionMapping; -import org.eclipse.persistence.internal.oxm.mappings.VariableXPathObjectMapping; -import org.eclipse.persistence.internal.oxm.mappings.XMLContainerMapping; +import org.eclipse.persistence.internal.oxm.mappings.*; import org.eclipse.persistence.internal.oxm.record.UnmarshalRecord; import org.eclipse.persistence.internal.oxm.record.XMLTransformationRecord; import org.eclipse.persistence.internal.queries.ContainerPolicy; @@ -116,16 +59,8 @@ import org.eclipse.persistence.jaxb.javamodel.JavaClass; import org.eclipse.persistence.jaxb.javamodel.JavaField; import org.eclipse.persistence.jaxb.javamodel.JavaMethod; -import org.eclipse.persistence.jaxb.xmlmodel.XmlAbstractNullPolicy; -import org.eclipse.persistence.jaxb.xmlmodel.XmlElementWrapper; -import org.eclipse.persistence.jaxb.xmlmodel.XmlIsSetNullPolicy; -import org.eclipse.persistence.jaxb.xmlmodel.XmlJavaTypeAdapter; +import org.eclipse.persistence.jaxb.xmlmodel.*; import org.eclipse.persistence.jaxb.xmlmodel.XmlJoinNodes.XmlJoinNode; -import org.eclipse.persistence.jaxb.xmlmodel.XmlNamedAttributeNode; -import org.eclipse.persistence.jaxb.xmlmodel.XmlNamedObjectGraph; -import org.eclipse.persistence.jaxb.xmlmodel.XmlNamedSubgraph; -import org.eclipse.persistence.jaxb.xmlmodel.XmlNullPolicy; -import org.eclipse.persistence.jaxb.xmlmodel.XmlTransformation; import org.eclipse.persistence.jaxb.xmlmodel.XmlTransformation.XmlReadTransformer; import org.eclipse.persistence.jaxb.xmlmodel.XmlTransformation.XmlWriteTransformer; import org.eclipse.persistence.logging.AbstractSessionLog; @@ -133,32 +68,10 @@ import org.eclipse.persistence.mappings.AttributeAccessor; import org.eclipse.persistence.mappings.DatabaseMapping; import org.eclipse.persistence.mappings.converters.Converter; -import org.eclipse.persistence.oxm.XMLConstants; -import org.eclipse.persistence.oxm.XMLDescriptor; -import org.eclipse.persistence.oxm.XMLField; -import org.eclipse.persistence.oxm.XMLMarshaller; -import org.eclipse.persistence.oxm.XMLUnmarshaller; -import org.eclipse.persistence.oxm.mappings.FixedMimeTypePolicy; +import org.eclipse.persistence.oxm.*; import org.eclipse.persistence.oxm.mappings.MimeTypePolicy; import org.eclipse.persistence.oxm.mappings.UnmarshalKeepAsElementPolicy; -import org.eclipse.persistence.oxm.mappings.XMLAnyAttributeMapping; -import org.eclipse.persistence.oxm.mappings.XMLAnyCollectionMapping; -import org.eclipse.persistence.oxm.mappings.XMLAnyObjectMapping; -import org.eclipse.persistence.oxm.mappings.XMLBinaryDataCollectionMapping; -import org.eclipse.persistence.oxm.mappings.XMLBinaryDataMapping; -import org.eclipse.persistence.oxm.mappings.XMLChoiceCollectionMapping; -import org.eclipse.persistence.oxm.mappings.XMLChoiceObjectMapping; -import org.eclipse.persistence.oxm.mappings.XMLCollectionReferenceMapping; -import org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping; -import org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping; -import org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping; -import org.eclipse.persistence.oxm.mappings.XMLDirectMapping; -import org.eclipse.persistence.oxm.mappings.XMLInverseReferenceMapping; -import org.eclipse.persistence.oxm.mappings.XMLMapping; -import org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping; -import org.eclipse.persistence.oxm.mappings.XMLTransformationMapping; -import org.eclipse.persistence.oxm.mappings.XMLVariableXPathCollectionMapping; -import org.eclipse.persistence.oxm.mappings.XMLVariableXPathObjectMapping; +import org.eclipse.persistence.oxm.mappings.*; import org.eclipse.persistence.oxm.mappings.converters.XMLConverter; import org.eclipse.persistence.oxm.mappings.converters.XMLListConverter; import org.eclipse.persistence.oxm.mappings.nullpolicy.AbstractNullPolicy; @@ -172,6 +85,15 @@ import org.eclipse.persistence.sessions.Project; import org.eclipse.persistence.sessions.Session; +import javax.xml.namespace.QName; +import javax.xml.transform.Source; +import java.awt.*; +import java.beans.Introspector; +import java.util.List; +import java.util.*; +import java.util.Queue; +import java.util.Map.Entry; + /** * INTERNAL: *

Purpose:To generate a TopLink OXM Project based on Java Class and TypeInfo information @@ -1982,86 +1904,86 @@ private Class generateMapEntryClass(String className, String keyType, String } String sig = "Ljava/lang/Object;Lorg/eclipse/persistence/internal/jaxb/many/MapEntry;"; - cw.visit(Opcodes.valueInt("ACC_PUBLIC") + Opcodes.valueInt("ACC_SUPER"), qualifiedInternalClassName, sig, "java/lang/Object", new String[] { "org/eclipse/persistence/internal/jaxb/many/MapEntry" }); + cw.visit(Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, qualifiedInternalClassName, sig, "java/lang/Object", new String[] { "org/eclipse/persistence/internal/jaxb/many/MapEntry" }); - cw.visitField(Opcodes.valueInt("ACC_PRIVATE"), "key", "L"+qualifiedInternalKeyClassName+";", null, null); + cw.visitField(Opcodes.ACC_PRIVATE, "key", "L"+qualifiedInternalKeyClassName+";", null, null); - cw.visitField(Opcodes.valueInt("ACC_PRIVATE"), "value", valuePrefix + qualifiedInternalValueClassName+";", null, null); + cw.visitField(Opcodes.ACC_PRIVATE, "value", valuePrefix + qualifiedInternalValueClassName+";", null, null); - MethodVisitor mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "", "()V", null, null); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), "java/lang/Object", "", "()V", false); - mv.visitInsn(Opcodes.valueInt("RETURN")); + MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "", "()V", null, null); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "", "()V", false); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(1, 1); mv.visitEnd(); - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "getKey", "()L"+qualifiedInternalKeyClassName+";", null, null); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitFieldInsn(Opcodes.valueInt("GETFIELD"), qualifiedInternalClassName, "key", "L"+qualifiedInternalKeyClassName+";"); - mv.visitInsn(Opcodes.valueInt("ARETURN")); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "getKey", "()L"+qualifiedInternalKeyClassName+";", null, null); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitFieldInsn(Opcodes.GETFIELD, qualifiedInternalClassName, "key", "L"+qualifiedInternalKeyClassName+";"); + mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(1, 1); mv.visitEnd(); - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "setKey", "(L"+qualifiedInternalKeyClassName+";)V", null, null); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - mv.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), qualifiedInternalClassName, "key", "L"+qualifiedInternalKeyClassName+";"); - mv.visitInsn(Opcodes.valueInt("RETURN")); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "setKey", "(L"+qualifiedInternalKeyClassName+";)V", null, null); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitVarInsn(Opcodes.ALOAD, 1); + mv.visitFieldInsn(Opcodes.PUTFIELD, qualifiedInternalClassName, "key", "L"+qualifiedInternalKeyClassName+";"); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(2, 2); mv.visitEnd(); - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "getValue", "()" + valuePrefix + qualifiedInternalValueClassName+";", null, null); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitFieldInsn(Opcodes.valueInt("GETFIELD"), qualifiedInternalClassName, "value", valuePrefix + qualifiedInternalValueClassName+";"); - mv.visitInsn(Opcodes.valueInt("ARETURN")); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "getValue", "()" + valuePrefix + qualifiedInternalValueClassName+";", null, null); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitFieldInsn(Opcodes.GETFIELD, qualifiedInternalClassName, "value", valuePrefix + qualifiedInternalValueClassName+";"); + mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(1, 1); mv.visitEnd(); - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "setValue", "(" + valuePrefix + qualifiedInternalValueClassName+";)V", null, null); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - mv.visitFieldInsn(Opcodes.valueInt("PUTFIELD"), qualifiedInternalClassName, "value", valuePrefix + qualifiedInternalValueClassName+";"); - mv.visitInsn(Opcodes.valueInt("RETURN")); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "setValue", "(" + valuePrefix + qualifiedInternalValueClassName+";)V", null, null); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitVarInsn(Opcodes.ALOAD, 1); + mv.visitFieldInsn(Opcodes.PUTFIELD, qualifiedInternalClassName, "value", valuePrefix + qualifiedInternalValueClassName+";"); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(2, 2); mv.visitEnd(); if(!qualifiedInternalValueClassName.equals("java/lang/Object")){ - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC") + Opcodes.valueInt("ACC_BRIDGE") + Opcodes.valueInt("ACC_SYNTHETIC"), "getValue", "()Ljava/lang/Object;", null, null); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), qualifiedInternalClassName, "getValue", "()" + valuePrefix + qualifiedInternalValueClassName+";", false); - mv.visitInsn(Opcodes.valueInt("ARETURN")); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_BRIDGE + Opcodes.ACC_SYNTHETIC, "getValue", "()Ljava/lang/Object;", null, null); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, qualifiedInternalClassName, "getValue", "()" + valuePrefix + qualifiedInternalValueClassName+";", false); + mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(1, 1); mv.visitEnd(); - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC") + Opcodes.valueInt("ACC_BRIDGE") + Opcodes.valueInt("ACC_SYNTHETIC"), "setValue", "(Ljava/lang/Object;)V", null, null); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_BRIDGE + Opcodes.ACC_SYNTHETIC, "setValue", "(Ljava/lang/Object;)V", null, null); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitVarInsn(Opcodes.ALOAD, 1); // CHECKCAST is slightly different for array types if (valuePrefix.equals("[L")) { - mv.visitTypeInsn(Opcodes.valueInt("CHECKCAST"), valuePrefix + qualifiedInternalValueClassName + ";"); + mv.visitTypeInsn(Opcodes.CHECKCAST, valuePrefix + qualifiedInternalValueClassName + ";"); } else { - mv.visitTypeInsn(Opcodes.valueInt("CHECKCAST"), qualifiedInternalValueClassName); + mv.visitTypeInsn(Opcodes.CHECKCAST, qualifiedInternalValueClassName); } - mv.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), qualifiedInternalClassName, "setValue", "(" + valuePrefix + qualifiedInternalValueClassName+";)V", false); - mv.visitInsn(Opcodes.valueInt("RETURN")); + mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, qualifiedInternalClassName, "setValue", "(" + valuePrefix + qualifiedInternalValueClassName+";)V", false); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(2, 2); mv.visitEnd(); } if(!qualifiedInternalKeyClassName.equals("java/lang/Object")){ - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC") + Opcodes.valueInt("ACC_BRIDGE") + Opcodes.valueInt("ACC_SYNTHETIC"), "getKey", "()Ljava/lang/Object;", null, null); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"),qualifiedInternalClassName, "getKey", "()L"+qualifiedInternalKeyClassName+";", false); - mv.visitInsn(Opcodes.valueInt("ARETURN")); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_BRIDGE + Opcodes.ACC_SYNTHETIC, "getKey", "()Ljava/lang/Object;", null, null); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL,qualifiedInternalClassName, "getKey", "()L"+qualifiedInternalKeyClassName+";", false); + mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(1, 1); mv.visitEnd(); - mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC") + Opcodes.valueInt("ACC_BRIDGE") + Opcodes.valueInt("ACC_SYNTHETIC"), "setKey", "(Ljava/lang/Object;)V", null, null); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 1); - mv.visitTypeInsn(Opcodes.valueInt("CHECKCAST"), qualifiedInternalKeyClassName); - mv.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), qualifiedInternalClassName, "setKey", "(L"+qualifiedInternalKeyClassName+";)V", false); - mv.visitInsn(Opcodes.valueInt("RETURN")); + mv = cw.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_BRIDGE + Opcodes.ACC_SYNTHETIC, "setKey", "(Ljava/lang/Object;)V", null, null); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitVarInsn(Opcodes.ALOAD, 1); + mv.visitTypeInsn(Opcodes.CHECKCAST, qualifiedInternalKeyClassName); + mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, qualifiedInternalClassName, "setKey", "(L"+qualifiedInternalKeyClassName+";)V", false); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(2, 2); mv.visitEnd(); } @@ -3248,7 +3170,7 @@ public Class generateWrapperClass(String className, String attributeType, boo ClassWriter cw = new EclipseLinkASMClassWriter(); String sig = null; - cw.visit(Opcodes.valueInt("ACC_PUBLIC"), className.replace(".", "/"), sig, Type.getType(WrappedValue.class).getInternalName(), null); + cw.visit(Opcodes.ACC_PUBLIC, className.replace(".", "/"), sig, Type.getType(WrappedValue.class).getInternalName(), null); String fieldType = null; if(isList){ @@ -3264,19 +3186,19 @@ public Class generateWrapperClass(String className, String attributeType, boo theQName = RESERVED_QNAME; } - MethodVisitor mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "", "()V", null, null); + MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "", "()V", null, null); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitTypeInsn(Opcodes.valueInt("NEW"), "javax/xml/namespace/QName"); - mv.visitInsn(Opcodes.valueInt("DUP")); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitTypeInsn(Opcodes.NEW, "javax/xml/namespace/QName"); + mv.visitInsn(Opcodes.DUP); mv.visitLdcInsn(theQName.getNamespaceURI()); mv.visitLdcInsn(theQName.getLocalPart()); - mv.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), "javax/xml/namespace/QName", "", "(Ljava/lang/String;Ljava/lang/String;)V", false); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "javax/xml/namespace/QName", "", "(Ljava/lang/String;Ljava/lang/String;)V", false); mv.visitLdcInsn(Type.getType(fieldType).unwrap()); - mv.visitInsn(Opcodes.valueInt("ACONST_NULL")); + mv.visitInsn(Opcodes.ACONST_NULL); - mv.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), "org/eclipse/persistence/internal/jaxb/WrappedValue", "", "(Ljavax/xml/namespace/QName;Ljava/lang/Class;Ljava/lang/Object;)V", false); - mv.visitInsn(Opcodes.valueInt("RETURN")); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "org/eclipse/persistence/internal/jaxb/WrappedValue", "", "(Ljavax/xml/namespace/QName;Ljava/lang/Class;Ljava/lang/Object;)V", false); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(5, 1); mv.visitEnd(); diff --git a/moxy/org.eclipse.persistence.moxy/src/test/java/org/eclipse/persistence/testing/jaxb/events/ClassLoaderTestCases.java b/moxy/org.eclipse.persistence.moxy/src/test/java/org/eclipse/persistence/testing/jaxb/events/ClassLoaderTestCases.java index 103ddfe0de7..5afd1ac740d 100644 --- a/moxy/org.eclipse.persistence.moxy/src/test/java/org/eclipse/persistence/testing/jaxb/events/ClassLoaderTestCases.java +++ b/moxy/org.eclipse.persistence.moxy/src/test/java/org/eclipse/persistence/testing/jaxb/events/ClassLoaderTestCases.java @@ -14,26 +14,20 @@ // Blaise Doughan - 2.3.4 - initial implementation package org.eclipse.persistence.testing.jaxb.events; -import java.io.StringReader; -import java.io.StringWriter; - import jakarta.xml.bind.JAXBContext; import jakarta.xml.bind.Marshaller; import jakarta.xml.bind.Unmarshaller; - import junit.framework.TestCase; - +import org.eclipse.persistence.asm.*; import org.eclipse.persistence.internal.jaxb.JaxbClassLoader; -import org.eclipse.persistence.asm.AnnotationVisitor; -import org.eclipse.persistence.asm.ClassWriter; -import org.eclipse.persistence.asm.EclipseLinkASMClassWriter; -import org.eclipse.persistence.asm.MethodVisitor; -import org.eclipse.persistence.asm.Opcodes; import org.eclipse.persistence.jaxb.JAXBContextFactory; import org.eclipse.persistence.jaxb.MarshallerProperties; import org.eclipse.persistence.jaxb.UnmarshallerProperties; import org.xml.sax.helpers.DefaultHandler; +import java.io.StringReader; +import java.io.StringWriter; + public class ClassLoaderTestCases extends TestCase { private static final String CLASS_NAME = "ClassLoaderChild"; @@ -45,16 +39,16 @@ public class ClassLoaderTestCases extends TestCase { protected void setUp() throws Exception { ClassWriter cw = new EclipseLinkASMClassWriter(); - cw.visit(Opcodes.valueInt("ACC_PUBLIC") + Opcodes.valueInt("ACC_SUPER"), CLASS_NAME, null, ClassLoaderRoot.class.getName().replace('.', '/'), null); + cw.visit(Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, CLASS_NAME, null, ClassLoaderRoot.class.getName().replace('.', '/'), null); AnnotationVisitor xmlTypeAV = cw.visitAnnotation("Ljakarta/xml/bind/annotation/XmlRootElement;", true); xmlTypeAV.visit("name", "root"); xmlTypeAV.visitEnd(); // Write Constructor: - MethodVisitor mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "", "()V", null, null); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), ClassLoaderRoot.class.getName().replace('.', '/'), "", "()V", false); - mv.visitInsn(Opcodes.valueInt("RETURN")); + MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "", "()V", null, null); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, ClassLoaderRoot.class.getName().replace('.', '/'), "", "()V", false); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(1, 1); mv.visitEnd(); diff --git a/sdo/org.eclipse.persistence.sdo/src/main/java/org/eclipse/persistence/sdo/helper/DynamicClassWriter.java b/sdo/org.eclipse.persistence.sdo/src/main/java/org/eclipse/persistence/sdo/helper/DynamicClassWriter.java index eccb408d803..c415bc65199 100644 --- a/sdo/org.eclipse.persistence.sdo/src/main/java/org/eclipse/persistence/sdo/helper/DynamicClassWriter.java +++ b/sdo/org.eclipse.persistence.sdo/src/main/java/org/eclipse/persistence/sdo/helper/DynamicClassWriter.java @@ -16,25 +16,20 @@ // implement correct interface. package org.eclipse.persistence.sdo.helper; -import java.io.ObjectStreamException; -import java.io.Serializable; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.List; - +import commonj.sdo.helper.HelperContext; +import org.eclipse.persistence.asm.*; +import org.eclipse.persistence.internal.security.PrivilegedAccessHelper; import org.eclipse.persistence.sdo.SDOConstants; import org.eclipse.persistence.sdo.SDODataObject; import org.eclipse.persistence.sdo.SDOProperty; import org.eclipse.persistence.sdo.SDOType; import org.eclipse.persistence.sdo.helper.extension.SDOUtil; -import org.eclipse.persistence.asm.ASMFactory; -import org.eclipse.persistence.asm.ClassWriter; -import org.eclipse.persistence.asm.MethodVisitor; -import org.eclipse.persistence.asm.Opcodes; -import org.eclipse.persistence.asm.Type; -import org.eclipse.persistence.internal.security.PrivilegedAccessHelper; -import commonj.sdo.helper.HelperContext; +import java.io.ObjectStreamException; +import java.io.Serializable; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.List; /* * Dynamically generate the implementation class for the SDO type. If the type has an instance @@ -109,11 +104,11 @@ public byte[] createClass() { ClassWriter cw = ASMFactory.createClassWriter(); if (null == type.getInstanceClass()) { - cw.visit(Opcodes.valueInt("ACC_PUBLIC") + Opcodes.valueInt("ACC_SUPER"), typeImplClassDescriptor, null, Type.getType(parentClass).getInternalName(), null); + cw.visit(Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, typeImplClassDescriptor, null, Type.getType(parentClass).getInternalName(), null); } else { String[] interfaces = new String[1]; interfaces[0] = type.getInstanceClassName().replace('.', '/'); - cw.visit(Opcodes.valueInt("ACC_PUBLIC") + Opcodes.valueInt("ACC_SUPER"), typeImplClassDescriptor, null, Type.getType(parentClass).getInternalName(), interfaces); + cw.visit(Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, typeImplClassDescriptor, null, Type.getType(parentClass).getInternalName(), interfaces); addPropertyIndices(cw); for (Object object : type.getDeclaredProperties()) { SDOProperty sdoProperty = (SDOProperty) object; @@ -130,7 +125,7 @@ public byte[] createClass() { } private void addPropertyIndices(ClassWriter cw) { - cw.visitField(Opcodes.valueInt("ACC_PUBLIC") + Opcodes.valueInt("ACC_FINAL") + Opcodes.valueInt("ACC_STATIC"), START_PROPERTY_INDEX, "I", null, startPropertyIndex).visitEnd(); + cw.visitField(Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL+ Opcodes.ACC_STATIC, START_PROPERTY_INDEX, "I", null, startPropertyIndex).visitEnd(); int declaredPropsSize = type.getDeclaredProperties().size(); Integer endPropertyIndex; @@ -139,14 +134,14 @@ private void addPropertyIndices(ClassWriter cw) { } else { endPropertyIndex = startPropertyIndex - 1; } - cw.visitField(Opcodes.valueInt("ACC_PUBLIC") + Opcodes.valueInt("ACC_FINAL") + Opcodes.valueInt("ACC_STATIC"), END_PROPERTY_INDEX, "I", null, endPropertyIndex).visitEnd(); + cw.visitField(Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL+ Opcodes.ACC_STATIC, END_PROPERTY_INDEX, "I", null, endPropertyIndex).visitEnd(); } private void addConstructors(ClassWriter cw) { - MethodVisitor mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "", Type.getMethodDescriptor(Type.VOID_TYPE), null, new String[] { Type.getInternalName(Serializable.class) }); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), Type.getType(parentClass).getInternalName(), "", Type.getMethodDescriptor(Type.VOID_TYPE), false); - mv.visitInsn(Opcodes.valueInt("RETURN")); + MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "", Type.getMethodDescriptor(Type.VOID_TYPE), null, new String[] { Type.getInternalName(Serializable.class) }); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, Type.getType(parentClass).getInternalName(), "", Type.getMethodDescriptor(Type.VOID_TYPE), false); + mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(1, 1); mv.visitEnd(); } @@ -171,24 +166,24 @@ private void addPropertyGetMethodInternal(ClassWriter cw, SDOProperty property, } else { propertyInstanceClassDescriptor = "L" + returnType.replace('.', '/') + ";"; } - MethodVisitor mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), outerGetMethodName, "()" + propertyInstanceClassDescriptor, null, null); + MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, outerGetMethodName, "()" + propertyInstanceClassDescriptor, null, null); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitIntInsn(Opcodes.valueInt("BIPUSH"), startPropertyIndex + property.getIndexInType()); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitIntInsn(Opcodes.BIPUSH, startPropertyIndex + property.getIndexInType()); String builtIn = SDOUtil.getBuiltInType(returnType); if (null != builtIn) { if (property.getType().isDataType() && !builtIn.equals(LIST)) { - mv.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), typeImplClassDescriptor, GET + builtIn, "(I)" + propertyInstanceClassDescriptor, false); - int iReturnOpcode = Type.getType(property.getType().getInstanceClass()).getOpcode(Opcodes.valueInt("IRETURN")); + mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, typeImplClassDescriptor, GET + builtIn, "(I)" + propertyInstanceClassDescriptor, false); + int iReturnOpcode = Type.getType(property.getType().getInstanceClass()).getOpcode(Opcodes.IRETURN); mv.visitInsn(iReturnOpcode); } else { - mv.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), typeImplClassDescriptor, GET, "(I)Ljava/lang/Object;", false); - mv.visitInsn(Opcodes.valueInt("ARETURN")); + mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, typeImplClassDescriptor, GET, "(I)Ljava/lang/Object;", false); + mv.visitInsn(Opcodes.ARETURN); } } else { - mv.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), typeImplClassDescriptor, GET, "(I)Ljava/lang/Object;", false); - mv.visitInsn(Opcodes.valueInt("ARETURN")); + mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, typeImplClassDescriptor, GET, "(I)Ljava/lang/Object;", false); + mv.visitInsn(Opcodes.ARETURN); } mv.visitMaxs(2, 1); mv.visitEnd(); @@ -207,29 +202,29 @@ private void addPropertySetMethod(ClassWriter cw, SDOProperty property) { } else { propertyInstanceClassDescriptor = "L" + returnType.replace('.', '/') + ";"; } - MethodVisitor mv = cw.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), outerSetMethodName, "(" + propertyInstanceClassDescriptor + ")V", null, null); + MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, outerSetMethodName, "(" + propertyInstanceClassDescriptor + ")V", null, null); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitIntInsn(Opcodes.valueInt("BIPUSH"), startPropertyIndex + property.getIndexInType()); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitIntInsn(Opcodes.BIPUSH, startPropertyIndex + property.getIndexInType()); String builtIn = SDOUtil.getBuiltInType(returnType); - int iLoadOpcode = Opcodes.valueInt("ALOAD"); + int iLoadOpcode = Opcodes.ALOAD; if (null != builtIn) { if (property.getType().isDataType() && !builtIn.equals(LIST)) { - iLoadOpcode = Type.getType(property.getType().getInstanceClass()).getOpcode(Opcodes.valueInt("ILOAD")); + iLoadOpcode = Type.getType(property.getType().getInstanceClass()).getOpcode(Opcodes.ILOAD); mv.visitVarInsn(iLoadOpcode, 1); - mv.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), typeImplClassDescriptor, SET + builtIn, "(I" + propertyInstanceClassDescriptor + ")V", false); + mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, typeImplClassDescriptor, SET + builtIn, "(I" + propertyInstanceClassDescriptor + ")V", false); } else { mv.visitVarInsn(iLoadOpcode, 1); - mv.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), typeImplClassDescriptor, SET, "(ILjava/lang/Object;)V", false); + mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, typeImplClassDescriptor, SET, "(ILjava/lang/Object;)V", false); } } else { mv.visitVarInsn(iLoadOpcode, 1); - mv.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), typeImplClassDescriptor, SET, "(ILjava/lang/Object;)V", false); + mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, typeImplClassDescriptor, SET, "(ILjava/lang/Object;)V", false); } - mv.visitInsn(Opcodes.valueInt("RETURN")); - if (iLoadOpcode == Opcodes.valueInt("DLOAD") || iLoadOpcode == Opcodes.valueInt("LLOAD")) { + mv.visitInsn(Opcodes.RETURN); + if (iLoadOpcode == Opcodes.DLOAD || iLoadOpcode == Opcodes.LLOAD) { mv.visitMaxs(4, 3); } else { mv.visitMaxs(3, 2); @@ -245,11 +240,11 @@ private void addWriteReplace(ClassWriter cw) { return; } - MethodVisitor mv = cw.visitMethod(Opcodes.valueInt("ACC_PROTECTED"), method.getName(), Type.getMethodDescriptor(method), null, new String[] { Type.getInternalName(ObjectStreamException.class) }); + MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PROTECTED, method.getName(), Type.getMethodDescriptor(method), null, new String[] { Type.getInternalName(ObjectStreamException.class) }); - mv.visitVarInsn(Opcodes.valueInt("ALOAD"), 0); - mv.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), Type.getInternalName(parentClass), method.getName(), Type.getMethodDescriptor(method), false); - mv.visitInsn(Opcodes.valueInt("ARETURN")); + mv.visitVarInsn(Opcodes.ALOAD, 0); + mv.visitMethodInsn(Opcodes.INVOKESPECIAL, Type.getInternalName(parentClass), method.getName(), Type.getMethodDescriptor(method), false); + mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(1, 1); mv.visitEnd(); } diff --git a/utils/eclipselink.utils.sigcompare/src/main/java/eclipselink/utils/sigcompare/SignatureImporter.java b/utils/eclipselink.utils.sigcompare/src/main/java/eclipselink/utils/sigcompare/SignatureImporter.java index 447ab8a79cb..6c409e71f13 100644 --- a/utils/eclipselink.utils.sigcompare/src/main/java/eclipselink/utils/sigcompare/SignatureImporter.java +++ b/utils/eclipselink.utils.sigcompare/src/main/java/eclipselink/utils/sigcompare/SignatureImporter.java @@ -14,6 +14,8 @@ // dclarke - initial sig compare utility (Bug 352151) package eclipselink.utils.sigcompare; +import org.eclipse.persistence.asm.*; + import java.io.File; import java.io.InputStream; import java.util.Enumeration; @@ -22,13 +24,6 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; -import org.eclipse.persistence.asm.ASMFactory; -import org.eclipse.persistence.asm.ClassReader; -import org.eclipse.persistence.asm.ClassVisitor; -import org.eclipse.persistence.asm.FieldVisitor; -import org.eclipse.persistence.asm.MethodVisitor; -import org.eclipse.persistence.asm.Opcodes; - public class SignatureImporter { @@ -42,7 +37,7 @@ public Map importSignatures(File jarFile) throws Excepti if (entry.getName().endsWith(".class")) { InputStream in = zipFile.getInputStream(entry); ClassReader reader = ASMFactory.createClassReader(in); - reader.accept(visitor, ClassReader.valueInt("SKIP_CODE") + ClassReader.valueInt("SKIP_DEBUG")); + reader.accept(visitor, ClassReader.SKIP_CODE + ClassReader.SKIP_DEBUG); in.close(); } } @@ -63,19 +58,19 @@ class SignatureClassVisitor extends ClassVisitor { protected ClassSignature sig = null; SignatureClassVisitor() { - super(Opcodes.valueInt("ASM5")); + super(Opcodes.ASM5); } @Override public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { - if ((access & Opcodes.valueInt("ACC_PUBLIC")) > 0) { + if ((access & Opcodes.ACC_PUBLIC) > 0) { this.sig = new ClassSignature(name, superName, interfaces); } // TODO: Handle inheritance } @Override public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { - if (this.sig != null && (access & Opcodes.valueInt("ACC_PUBLIC")) > 0) { + if (this.sig != null && (access & Opcodes.ACC_PUBLIC) > 0) { this.sig.addField(name, desc); } return null; @@ -83,7 +78,7 @@ public FieldVisitor visitField(int access, String name, String desc, String sign @Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { - if (this.sig != null && (access & Opcodes.valueInt("ACC_PUBLIC")) > 0) { + if (this.sig != null && (access & Opcodes.ACC_PUBLIC) > 0) { this.sig.addMethod(name, desc); } return null;