From: <pj...@us...> - 2009-06-08 00:54:16
|
Revision: 6467 http://jython.svn.sourceforge.net/jython/?rev=6467&view=rev Author: pjenvey Date: 2009-06-08 00:30:12 +0000 (Mon, 08 Jun 2009) Log Message: ----------- don't reference the APIVersion field directly so it's not hardcoded into the .class Modified Paths: -------------- trunk/jython/src/org/python/compiler/ClassFile.java trunk/jython/src/org/python/core/imp.java Modified: trunk/jython/src/org/python/compiler/ClassFile.java =================================================================== --- trunk/jython/src/org/python/compiler/ClassFile.java 2009-06-07 23:36:06 UTC (rev 6466) +++ trunk/jython/src/org/python/compiler/ClassFile.java 2009-06-08 00:30:12 UTC (rev 6467) @@ -1,6 +1,6 @@ // Copyright (c) Corporation for National Research Initiatives - package org.python.compiler; + import java.io.ByteArrayOutputStream; import java.io.FileOutputStream; import java.io.IOException; @@ -15,6 +15,8 @@ import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; +import org.python.core.imp; + public class ClassFile { ClassWriter cw; @@ -53,8 +55,8 @@ this.mtime = mtime; cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); - methodVisitors = Collections.synchronizedList(new ArrayList()); - fieldVisitors = Collections.synchronizedList(new ArrayList()); + methodVisitors = Collections.synchronizedList(new ArrayList<MethodVisitor>()); + fieldVisitors = Collections.synchronizedList(new ArrayList<FieldVisitor>()); } public void setSource(String name) { @@ -96,7 +98,7 @@ throws IOException { for (int i=0; i<methodVisitors.size(); i++) { - MethodVisitor mv = (MethodVisitor)methodVisitors.get(i); + MethodVisitor mv = methodVisitors.get(i); mv.visitMaxs(0,0); mv.visitEnd(); } @@ -105,8 +107,9 @@ public void write(OutputStream stream) throws IOException { cw.visit(Opcodes.V1_5, Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, this.name, null, this.superclass, interfaces); AnnotationVisitor av = cw.visitAnnotation("Lorg/python/compiler/APIVersion;", true); - //XXX: should imp.java really house this value or should imp.java point into org.python.compiler? - av.visit("value", new Integer(org.python.core.imp.APIVersion)); + // XXX: should imp.java really house this value or should imp.java point into + // org.python.compiler? + av.visit("value", new Integer(imp.getAPIVersion())); av.visitEnd(); av = cw.visitAnnotation("Lorg/python/compiler/MTime;", true); @@ -127,11 +130,4 @@ //debug(baos); baos.close(); } - - //XXX: this should go away when things stabilize. - private void debug(ByteArrayOutputStream baos) throws IOException { - FileOutputStream fos = new FileOutputStream("DEBUG.class"); - baos.writeTo(fos); - fos.close(); - } } Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2009-06-07 23:36:06 UTC (rev 6466) +++ trunk/jython/src/org/python/core/imp.java 2009-06-08 00:30:12 UTC (rev 6467) @@ -20,7 +20,7 @@ private static final String UNKNOWN_SOURCEFILE = "<unknown>"; - public static final int APIVersion = 22; + private static final int APIVersion = 22; public static final int NO_MTIME = -1; @@ -990,4 +990,8 @@ modules.__setitem__(modName, ret); return ret; } + + public static int getAPIVersion() { + return APIVersion; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |