[jython] Port to objectweb-asm 5

Mat Booth mbooth at fedoraproject.org
Mon Jun 2 15:42:42 UTC 2014


commit 97c0e9e52d732b19bb883ec10e4e3cbf12d12022
Author: Mat Booth <mat.booth at redhat.com>
Date:   Mon Jun 2 16:00:40 2014 +0100

    Port to objectweb-asm 5

 jython-new-asm.patch |  256 ++++++++++++++++++++++++++++++++++++++++++++++++++
 jython.spec          |   16 ++-
 2 files changed, 267 insertions(+), 5 deletions(-)
---
diff --git a/jython-new-asm.patch b/jython-new-asm.patch
new file mode 100644
index 0000000..89eeafb
--- /dev/null
+++ b/jython-new-asm.patch
@@ -0,0 +1,256 @@
+--- src/org/python/expose/generate/ExposedTypeProcessor.java.asm	2014-05-30 14:02:34.000000000 +0100
++++ src/org/python/expose/generate/ExposedTypeProcessor.java	2014-06-02 12:44:39.449676939 +0100
+@@ -8,12 +8,10 @@
+ 
+ import org.python.expose.ExposedType;
+ import org.objectweb.asm.AnnotationVisitor;
+-import org.objectweb.asm.ClassAdapter;
+ import org.objectweb.asm.ClassReader;
+ import org.objectweb.asm.ClassVisitor;
+ import org.objectweb.asm.ClassWriter;
+ import org.objectweb.asm.FieldVisitor;
+-import org.objectweb.asm.MethodAdapter;
+ import org.objectweb.asm.MethodVisitor;
+ import org.objectweb.asm.Opcodes;
+ import org.objectweb.asm.Type;
+@@ -105,7 +103,7 @@
+     /**
+      * The actual visitor that runs over the bytecode and figures out what to expose.
+      */
+-    private final class TypeProcessor extends ClassAdapter {
++    private final class TypeProcessor extends ClassVisitor {
+ 
+         private Type baseType = OBJECT;
+ 
+@@ -116,7 +114,7 @@
+         private boolean generatedStaticBlock;
+ 
+         private TypeProcessor(ClassVisitor cv) {
+-            super(cv);
++            super(Opcodes.ASM4, cv);
+         }
+ 
+         @Override
+@@ -227,7 +225,7 @@
+                                                                            desc,
+                                                                            signature,
+                                                                            exceptions);
+-                return new MethodAdapter(passthroughVisitor) {
++                return new MethodVisitor(Opcodes.ASM4, passthroughVisitor) {
+ 
+                     @Override
+                     public void visitCode() {
+--- src/org/python/expose/generate/ExposedMethodFinder.java.asm	2014-05-30 14:02:34.000000000 +0100
++++ src/org/python/expose/generate/ExposedMethodFinder.java	2014-06-02 12:44:39.448676955 +0100
+@@ -4,7 +4,6 @@
+ 
+ import org.python.expose.MethodType;
+ import org.objectweb.asm.AnnotationVisitor;
+-import org.objectweb.asm.MethodAdapter;
+ import org.objectweb.asm.MethodVisitor;
+ import org.objectweb.asm.Opcodes;
+ import org.objectweb.asm.Type;
+@@ -15,7 +14,7 @@
+  * annotation is visited, calls handleResult with the exposer constructed with that annotation. Only
+  * one of the handleResult methods will be called, if any.
+  */
+-public abstract class ExposedMethodFinder extends MethodAdapter implements PyTypes, Opcodes {
++public abstract class ExposedMethodFinder extends MethodVisitor implements PyTypes, Opcodes {
+ 
+     private Exposer newExp;
+ 
+@@ -36,7 +35,7 @@
+                                String desc,
+                                String[] exceptions,
+                                MethodVisitor delegate) {
+-        super(delegate);
++        super(Opcodes.ASM4, delegate);
+         this.typeName = typeName;
+         this.onType = onType;
+         this.access = access;
+@@ -136,6 +135,10 @@
+ 
+     class ExposedMethodVisitor extends RestrictiveAnnotationVisitor {
+ 
++        public ExposedMethodVisitor() {
++            super();
++        }
++
+         @Override
+         public void visit(String name, Object value) {
+             if (name.equals("doc")) {
+--- src/org/python/expose/generate/RestrictiveAnnotationVisitor.java.asm	2014-05-30 14:02:34.000000000 +0100
++++ src/org/python/expose/generate/RestrictiveAnnotationVisitor.java	2014-06-02 12:46:40.971638164 +0100
+@@ -1,12 +1,17 @@
+ package org.python.expose.generate;
+ 
+ import org.objectweb.asm.AnnotationVisitor;
++import org.objectweb.asm.Opcodes;
+ 
+ /**
+  * An Annotation visitor that throws an IllegalArgumentException if it visits anything other than
+  * visitEnd. Should be subclasses by something interested in only certain events.
+  */
+-public class RestrictiveAnnotationVisitor implements AnnotationVisitor {
++public class RestrictiveAnnotationVisitor extends AnnotationVisitor {
++
++    public RestrictiveAnnotationVisitor() {
++        super(Opcodes.ASM4);
++    }
+ 
+     public AnnotationVisitor visitAnnotation(String name, String desc) {
+         throw new IllegalArgumentException("Unknown annotation field '" + name + "'");
+--- src/org/python/expose/generate/ExposedFieldFinder.java.asm	2014-05-30 14:02:34.000000000 +0100
++++ src/org/python/expose/generate/ExposedFieldFinder.java	2014-06-02 12:47:19.549992964 +0100
+@@ -3,8 +3,9 @@
+ import org.objectweb.asm.AnnotationVisitor;
+ import org.objectweb.asm.Attribute;
+ import org.objectweb.asm.FieldVisitor;
++import org.objectweb.asm.Opcodes;
+ 
+-public abstract class ExposedFieldFinder implements FieldVisitor, PyTypes {
++public abstract class ExposedFieldFinder extends FieldVisitor implements PyTypes {
+ 
+     private String fieldName;
+ 
+@@ -13,6 +14,7 @@
+     private String doc;
+ 
+     public ExposedFieldFinder(String name, FieldVisitor delegate) {
++        super(Opcodes.ASM4);
+         fieldName = name;
+         this.delegate = delegate;
+     }
+--- src/org/python/core/AnnotationReader.java.asm	2014-05-30 14:02:34.000000000 +0100
++++ src/org/python/core/AnnotationReader.java	2014-06-02 12:51:42.317618236 +0100
+@@ -8,7 +8,8 @@
+ 
+ import org.objectweb.asm.AnnotationVisitor;
+ import org.objectweb.asm.ClassReader;
+-import org.objectweb.asm.commons.EmptyVisitor;
++import org.objectweb.asm.ClassVisitor;
++import org.objectweb.asm.Opcodes;
+ 
+ /**
+  * This class reads a classfile from a byte array and pulls out the value of the class annotation
+@@ -19,7 +20,7 @@
+  * cost too much, we will want to implement a special purpose ClassReader that only reads out the
+  * APIVersion annotation I think.
+  */
+-public class AnnotationReader extends EmptyVisitor {
++public class AnnotationReader extends ClassVisitor {
+ 
+     private boolean nextVisitIsVersion = false;
+     private boolean nextVisitIsMTime = false;
+@@ -32,6 +33,7 @@
+      * @throws IOException - if the classfile is malformed.
+      */
+     public AnnotationReader(byte[] data) throws IOException {
++        super(Opcodes.ASM4);
+         ClassReader r;
+         try {
+             r = new ClassReader(data);
+@@ -43,21 +45,22 @@
+         }
+         r.accept(this, 0);
+     }
+-
++    
++    @Override
+     public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
+         nextVisitIsVersion = desc.equals("Lorg/python/compiler/APIVersion;");
+         nextVisitIsMTime = desc.equals("Lorg/python/compiler/MTime;");
+-        return this;
+-    }
+-
+-    public void visit(String name, Object value) {
+-        if (nextVisitIsVersion) {
+-            version = (Integer)value;
+-            nextVisitIsVersion = false;
+-        } else if (nextVisitIsMTime) {
+-            mtime = (Long)value;
+-            nextVisitIsVersion = false;
+-        }
++        return new AnnotationVisitor(Opcodes.ASM4) {
++            public void visit(String name, Object value) {
++                if (nextVisitIsVersion) {
++                    version = (Integer)value;
++                    nextVisitIsVersion = false;
++                } else if (nextVisitIsMTime) {
++                    mtime = (Long)value;
++                    nextVisitIsVersion = false;
++                }
++            }
++        };
+     }
+ 
+     public int getVersion() {
+--- src/org/python/compiler/Code.java.asm	2014-05-30 14:02:34.000000000 +0100
++++ src/org/python/compiler/Code.java	2014-06-02 12:44:39.447676972 +0100
+@@ -5,11 +5,12 @@
+ 
+ import org.objectweb.asm.AnnotationVisitor;
+ import org.objectweb.asm.Attribute;
++import org.objectweb.asm.Handle;
+ import org.objectweb.asm.Label;
+ import org.objectweb.asm.MethodVisitor;
+ import org.objectweb.asm.Opcodes;
+ 
+-class Code implements MethodVisitor, Opcodes {
++class Code extends MethodVisitor implements Opcodes {
+     MethodVisitor mv;
+     String sig;
+     String locals[];
+@@ -21,6 +22,7 @@
+     //XXX: I'd really like to get sig and access out of here since MethodVistitor
+     //     should already have this information.
+     public Code(MethodVisitor mv, String sig, int access) {
++        super(ASM4);
+         this.mv = mv;
+         this.sig = sig;
+         nlocals = -sigSize(sig, false);
+@@ -163,7 +165,7 @@
+         return mv.visitParameterAnnotation(arg0, arg1, arg2);
+     }
+ 
+-    public void visitTableSwitchInsn(int arg0, int arg1, Label arg2, Label[] arg3) {
++    public void visitTableSwitchInsn(int arg0, int arg1, Label arg2, Label... arg3) {
+         mv.visitTableSwitchInsn(arg0, arg1, arg2, arg3);
+     }
+ 
+@@ -598,4 +600,11 @@
+     public void setline(int line) {
+         mv.visitLineNumber(line, new Label());
+     }
++
++    @Override
++    public void visitInvokeDynamicInsn(String name, String descriptor, Handle bsmHandle, 
++                                       Object... bmsArgs) {
++        mv.visitInvokeDynamicInsn(name, descriptor, bsmHandle, bmsArgs);
++    }
++    
+ }
+--- tests/java/org/python/expose/generate/ExposeMethodFinderTest.java.asm	2014-05-30 14:02:34.000000000 +0100
++++ tests/java/org/python/expose/generate/ExposeMethodFinderTest.java	2014-06-02 12:44:39.450676922 +0100
+@@ -3,11 +3,9 @@
+ import junit.framework.TestCase;
+ 
+ import org.objectweb.asm.AnnotationVisitor;
++import org.objectweb.asm.MethodVisitor;
+ import org.objectweb.asm.Opcodes;
+ import org.objectweb.asm.Type;
+-import org.objectweb.asm.commons.EmptyVisitor;
+-import org.python.expose.ExposedMethod;
+-import org.python.expose.ExposedNew;
+ 
+ public class ExposeMethodFinderTest extends TestCase implements Opcodes, PyTypes {
+ 
+@@ -18,7 +16,7 @@
+                                        methodName,
+                                        descriptor,
+                                        null,
+-                                       new EmptyVisitor()) {
++                                       new MethodVisitor(Opcodes.ASM4) {}) {
+ 
+             @Override
+             public void handleResult(InstanceMethodExposer exposer) {
diff --git a/jython.spec b/jython.spec
index 172d91a..f6e9a0b 100644
--- a/jython.spec
+++ b/jython.spec
@@ -6,7 +6,7 @@
 
 Name:                      jython
 Version:                   2.5.3
-Release:                   1%{?dist}
+Release:                   2%{?dist}
 Summary:                   A Java implementation of the Python language
 License:                   ASL 1.1 and BSD and CNRI and JPython and Python
 URL:                       http://www.jython.org/
@@ -26,12 +26,14 @@ Patch2:                    jython-CVE-2013-2027.patch
 Patch3:                    jython-new-jnr.patch
 # This is backported from upstream to support the newer version of guava in Fedora
 Patch4:                    jython-new-guava.patch
+# This is backported from upstream to support the newer version of asm in Fedora
+Patch5:                    jython-new-asm.patch
 
 Requires:                  python >= %{cpython_version}
 Requires:                  libreadline-java >= 0.8.0-16
 Requires:                  antlr32-java
 Requires:                  guava
-Requires:                  objectweb-asm3
+Requires:                  objectweb-asm
 Requires:                  jnr-constants
 Requires:                  jnr-ffi
 Requires:                  jnr-posix
@@ -46,7 +48,7 @@ BuildRequires:             python >= %{cpython_version}
 BuildRequires:             libreadline-java >= 0.8.0-16
 BuildRequires:             antlr32-tool
 BuildRequires:             guava
-BuildRequires:             objectweb-asm3
+BuildRequires:             objectweb-asm
 BuildRequires:             jnr-constants
 BuildRequires:             jnr-ffi
 BuildRequires:             jnr-posix
@@ -99,13 +101,14 @@ Demonstrations and samples for %{name}.
 %patch2
 %patch3 -p1
 %patch4 -p1
+%patch5
 
 %build
 build-jar-repository -s extlibs \
   antlr32/antlr antlr32/antlr-runtime stringtemplate antlr \
   jnr-constants jnr-ffi jnr-posix jffi \
   libreadline-java/libreadline-java jline1/jline-1 \
-  glassfish-servlet-api guava objectweb-asm3/asm objectweb-asm3/asm-commons \
+  glassfish-servlet-api guava objectweb-asm/asm objectweb-asm/asm-commons \
   junit
 
 ant \
@@ -175,7 +178,7 @@ esac
 # Configuration
 MAIN_CLASS=org.python.util.jython
 BASE_FLAGS=-Dpython.home=%{_datadir}/jython
-BASE_JARS="jython/jython guava jnr-constants jnr-ffi jnr-posix jffi jline1/jline-1 antlr32/antlr-runtime objectweb-asm3/asm objectweb-asm3/asm-commons"
+BASE_JARS="jython/jython guava jnr-constants jnr-ffi jnr-posix jffi jline1/jline-1 antlr32/antlr-runtime objectweb-asm/asm objectweb-asm/asm-commons"
 
 BASE_FLAGS="\$BASE_FLAGS -Dpython.console=org.python.util.ReadlineConsole"
 BASE_FLAGS="\$BASE_FLAGS -Djava.library.path=\$JYTHONLIBDIR/libreadline-java"
@@ -213,6 +216,9 @@ EOF
 %{_datadir}/%{name}/Demo
 
 %changelog
+* Mon Jun 02 2014 Mat Booth <mat.booth at redhat.com> - 2.5.3-2
+- Port to objectweb-asm 5
+
 * Wed May 28 2014 Mat Booth <mat.booth at redhat.com> - 2.5.3-1
 - Updated to latest stable upstream release 2.5.3
 - Backported patches for guava and jnr support


More information about the scm-commits mailing list