[Jython-checkins] jython: Fix the AnnotationReader to pass the correct AnnotationVisitor wrt ASM4. Fixes
frank.wierzbicki
jython-checkins at python.org
Wed Mar 14 04:09:31 CET 2012
http://hg.python.org/jython/rev/1afee01eac12
changeset: 6338:1afee01eac12
user: Shashank Bharadwaj <shanka.mns at gmail.com>
date: Tue Mar 13 12:55:33 2012 -0700
summary:
Fix the AnnotationReader to pass the correct AnnotationVisitor wrt ASM4. Fixes a few of Java integration/visibility issues.
There are a few more test failures, and the fix will be on it's way soon.
files:
src/org/python/core/AnnotationReader.java | 21 +-
src/org/python/expose/generate/DescriptorVisitor.java | 1 +
src/org/python/expose/generate/ExposedFieldFinder.java | 2 +-
src/org/python/expose/generate/RestrictiveAnnotationVisitor.java | 7 +-
src/org/python/modules/jffi/AsmClassBuilder.java | 2 +-
src/org/python/modules/jffi/EmptyVisitor.java | 93 ----------
src/org/python/modules/jffi/SkinnyMethodAdapter.java | 23 +-
7 files changed, 24 insertions(+), 125 deletions(-)
diff --git a/src/org/python/core/AnnotationReader.java b/src/org/python/core/AnnotationReader.java
--- a/src/org/python/core/AnnotationReader.java
+++ b/src/org/python/core/AnnotationReader.java
@@ -50,17 +50,18 @@
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
nextVisitIsVersion = desc.equals("Lorg/python/compiler/APIVersion;");
nextVisitIsMTime = desc.equals("Lorg/python/compiler/MTime;");
- return super.visitAnnotation(desc, visible);
- }
+ 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 void visit(String name, Object value) {
+ if (nextVisitIsVersion) {
+ version = (Integer)value;
+ nextVisitIsVersion = false;
+ } else if (nextVisitIsMTime) {
+ mtime = (Long)value;
+ nextVisitIsVersion = false;
+ }
+ }
+ };
}
public int getVersion() {
diff --git a/src/org/python/expose/generate/DescriptorVisitor.java b/src/org/python/expose/generate/DescriptorVisitor.java
--- a/src/org/python/expose/generate/DescriptorVisitor.java
+++ b/src/org/python/expose/generate/DescriptorVisitor.java
@@ -12,6 +12,7 @@
@Override
public void visit(String name, Object value) {
+ System.err.println("DescriptorVisitor::visit:: " + name + " value: " + value);
if (name.equals("name")) {
val = (String)value;
} else if (name.equals("doc")) {
diff --git a/src/org/python/expose/generate/ExposedFieldFinder.java b/src/org/python/expose/generate/ExposedFieldFinder.java
--- a/src/org/python/expose/generate/ExposedFieldFinder.java
+++ b/src/org/python/expose/generate/ExposedFieldFinder.java
@@ -14,7 +14,7 @@
private String doc;
public ExposedFieldFinder(String name, FieldVisitor delegate) {
- super(Opcodes.ASM4, delegate);
+ super(Opcodes.ASM4);
fieldName = name;
this.delegate = delegate;
}
diff --git a/src/org/python/expose/generate/RestrictiveAnnotationVisitor.java b/src/org/python/expose/generate/RestrictiveAnnotationVisitor.java
--- a/src/org/python/expose/generate/RestrictiveAnnotationVisitor.java
+++ b/src/org/python/expose/generate/RestrictiveAnnotationVisitor.java
@@ -9,12 +9,9 @@
*/
public class RestrictiveAnnotationVisitor extends AnnotationVisitor {
- public RestrictiveAnnotationVisitor(int arg0) {
- super(arg0);
- }
-
public RestrictiveAnnotationVisitor() {
- this(Opcodes.ASM4);
+ super(Opcodes.ASM4);
+ System.err.println("RestrictiveAnnotationVisitor:: constructed ");
}
public AnnotationVisitor visitAnnotation(String name, String desc) {
diff --git a/src/org/python/modules/jffi/AsmClassBuilder.java b/src/org/python/modules/jffi/AsmClassBuilder.java
--- a/src/org/python/modules/jffi/AsmClassBuilder.java
+++ b/src/org/python/modules/jffi/AsmClassBuilder.java
@@ -142,7 +142,7 @@
Constructor<? extends ClassVisitor> c = tmvClass.getDeclaredConstructor(PrintWriter.class);
return c.newInstance(out);
} catch (Throwable t) {
- return new EmptyVisitor();
+ return null;
}
}
diff --git a/src/org/python/modules/jffi/EmptyVisitor.java b/src/org/python/modules/jffi/EmptyVisitor.java
deleted file mode 100644
--- a/src/org/python/modules/jffi/EmptyVisitor.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package org.python.modules.jffi;
-
-import org.objectweb.asm.AnnotationVisitor;
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.FieldVisitor;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-
-
-public class EmptyVisitor extends ClassVisitor {
-
- AnnotationVisitor av = new AnnotationVisitor(Opcodes.ASM4) {
-
- @Override
- public AnnotationVisitor visitAnnotation(
- String name,
- String desc)
- {
- return this;
- }
-
- @Override
- public AnnotationVisitor visitArray(String name) {
- return this;
- }
- };
-
- public EmptyVisitor() {
- super(Opcodes.ASM4);
- }
-
- @Override
- public AnnotationVisitor visitAnnotation(
- String desc,
- boolean visible)
- {
- return av;
- }
-
- @Override
- public FieldVisitor visitField(
- int access,
- String name,
- String desc,
- String signature,
- Object value)
- {
- return new FieldVisitor(Opcodes.ASM4) {
-
- @Override
- public AnnotationVisitor visitAnnotation(
- String desc,
- boolean visible)
- {
- return av;
- }
- };
- }
-
- @Override
- public MethodVisitor visitMethod(
- int access,
- String name,
- String desc,
- String signature,
- String[] exceptions)
- {
- return new MethodVisitor(Opcodes.ASM4) {
-
- @Override
- public AnnotationVisitor visitAnnotationDefault() {
- return av;
- }
-
- @Override
- public AnnotationVisitor visitAnnotation(
- String desc,
- boolean visible)
- {
- return av;
- }
-
- @Override
- public AnnotationVisitor visitParameterAnnotation(
- int parameter,
- String desc,
- boolean visible)
- {
- return av;
- }
- };
- }
-}
\ No newline at end of file
diff --git a/src/org/python/modules/jffi/SkinnyMethodAdapter.java b/src/org/python/modules/jffi/SkinnyMethodAdapter.java
--- a/src/org/python/modules/jffi/SkinnyMethodAdapter.java
+++ b/src/org/python/modules/jffi/SkinnyMethodAdapter.java
@@ -10,7 +10,8 @@
package org.python.modules.jffi;
import org.objectweb.asm.*;
-import org.objectweb.asm.util.ASMifier;
+import org.objectweb.asm.util.Printer;
+import org.objectweb.asm.util.Textifier;
import org.objectweb.asm.util.TraceMethodVisitor;
import java.io.PrintStream;
@@ -25,33 +26,25 @@
public class SkinnyMethodAdapter extends MethodVisitor implements Opcodes {
private final static boolean DEBUG = Boolean.getBoolean("jython.compile.dump");
private MethodVisitor method;
+ private Printer printer;
private String name;
private ClassVisitor cv;
- /** Creates a new instance of SkinnyMethodAdapter */
- public SkinnyMethodAdapter(MethodVisitor method) {
- super(Opcodes.ASM4);
- setMethodVisitor(method);
- }
-
public SkinnyMethodAdapter(ClassVisitor cv, int flags, String name, String signature, String something, String[] exceptions) {
- super(Opcodes.ASM4);
+ super(ASM4);
setMethodVisitor(cv.visitMethod(flags, name, signature, something, exceptions));
this.cv = cv;
this.name = name;
}
- public SkinnyMethodAdapter() {
- super(Opcodes.ASM4);
- }
-
public MethodVisitor getMethodVisitor() {
return method;
}
public void setMethodVisitor(MethodVisitor mv) {
if (DEBUG) {
- this.method = new TraceMethodVisitor(mv, new ASMifier());
+ this.printer = new Textifier();
+ this.method = new TraceMethodVisitor(mv, printer);
} else {
this.method = mv;
}
@@ -533,7 +526,7 @@
} else {
pw.write("*** Dumping ***\n");
}
- ((TraceMethodVisitor)getMethodVisitor()).p.print(pw);
+ printer.print(pw);
pw.flush();
}
getMethodVisitor().visitMaxs(1, 1);
@@ -898,7 +891,7 @@
if (DEBUG) {
PrintWriter pw = new PrintWriter(System.out);
pw.write("*** Dumping ***\n");
- ((TraceMethodVisitor)getMethodVisitor()).p.print(pw);
+ printer.print(pw);
pw.flush();
}
getMethodVisitor().visitMaxs(arg0, arg1);
--
Repository URL: http://hg.python.org/jython
More information about the Jython-checkins
mailing list