From: <fd...@us...> - 2007-09-15 00:33:47
|
Revision: 3498 http://jnode.svn.sourceforge.net/jnode/?rev=3498&view=rev Author: fduminy Date: 2007-09-14 17:33:44 -0700 (Fri, 14 Sep 2007) Log Message: ----------- fixed AnnotateTask and re-enabled it in the build process Modified Paths: -------------- trunk/all/build.xml trunk/all/lib/jnode.xml trunk/builder/src/builder/org/jnode/ant/taskdefs/AnnotateTask.java trunk/core/src/openjdk/sun/sun/misc/SharedSecrets.java Modified: trunk/all/build.xml =================================================================== --- trunk/all/build.xml 2007-09-14 11:30:08 UTC (rev 3497) +++ trunk/all/build.xml 2007-09-15 00:33:44 UTC (rev 3498) @@ -166,7 +166,7 @@ </target> <!-- Assemble all plugins --> - <target name="assemble-plugins" depends="assemble-projects"> + <target name="assemble-plugins" depends="assemble-projects,openjdk-annotate"> <!-- Now assemble all plugins --> <taskdef name="plugin" classname="org.jnode.build.PluginTask" classpathref="cp-jnode"/> <plugin todir="${plugins.dir}" tmpdir="${build.dir}/tmp/plugins" pluginDir="${descriptors.dir}"> @@ -637,7 +637,8 @@ <taskdef name="oj-annotate" classname="org.jnode.ant.taskdefs.AnnotateTask" classpathref="cp-jnode"/> - <oj-annotate annotationFile="${root.dir}/all/conf/openjdk-annotations.properties"> + <oj-annotate annotationFile="${root.dir}/all/conf/openjdk-annotations.properties" + trace="false"> <fileset dir="${root.dir}/core/build/classes"> <patternset includes="**/*.class"/> </fileset> Modified: trunk/all/lib/jnode.xml =================================================================== --- trunk/all/lib/jnode.xml 2007-09-14 11:30:08 UTC (rev 3497) +++ trunk/all/lib/jnode.xml 2007-09-15 00:33:44 UTC (rev 3498) @@ -14,7 +14,7 @@ target="${java.target}" source="${java.source}" encoding="${java.encoding}" - excludes="**/*-template.java,**/package-info.java, **/AnnotateTask.java"> + excludes="**/*-template.java,**/package-info.java"> <bootclasspath path="${jnode-core.jar}"/> <compilerarg value="${compilerarg}"/> </javac> Modified: trunk/builder/src/builder/org/jnode/ant/taskdefs/AnnotateTask.java =================================================================== --- trunk/builder/src/builder/org/jnode/ant/taskdefs/AnnotateTask.java 2007-09-14 11:30:08 UTC (rev 3497) +++ trunk/builder/src/builder/org/jnode/ant/taskdefs/AnnotateTask.java 2007-09-15 00:33:44 UTC (rev 3498) @@ -23,7 +23,6 @@ import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -41,9 +40,11 @@ import org.objectweb.asm.ClassWriter; import org.objectweb.asm.Type; import org.objectweb.asm.attrs.Annotation; +import org.objectweb.asm.attrs.Attributes; import org.objectweb.asm.attrs.RuntimeVisibleAnnotations; -import org.objectweb.asm.util.AbstractVisitor; -import org.objectweb.asm.util.CheckClassAdapter; +//import org.objectweb.asm.util.AbstractVisitor; +//import org.objectweb.asm.util.CheckClassAdapter; +//import org.objectweb.asm.util.TraceClassVisitor; import org.objectweb.asm.util.TraceClassVisitor; /** @@ -59,6 +60,7 @@ private File annotationFile; private String[] classesFiles; + private boolean trace = true; public void execute() throws BuildException { classesFiles = readProperties(annotationFile); @@ -72,6 +74,11 @@ public final void setAnnotationFile(File annotationFile) { this.annotationFile = annotationFile; } + + public final void setTrace(boolean trace) + { + this.trace = trace; + } /** * Read the properties file. For now, it simply contains a list of @@ -166,9 +173,19 @@ try { + if(trace) + { + traceClass(file, "before"); + } + fis = new FileInputStream(file); fos = new FileOutputStream(tmpFile); addAnnotation(file.getName(), fis, fos); + + if(trace) + { + traceClass(file, "after"); + } } finally { @@ -184,12 +201,12 @@ if(!file.delete()) { - throw new IOException("can delete "+file.getAbsolutePath()); + throw new IOException("can't delete "+file.getAbsolutePath()); } if(!tmpFile.renameTo(file)) { - throw new IOException("can rename "+tmpFile.getAbsolutePath()); + throw new IOException("can't rename "+tmpFile.getAbsolutePath()); } //traceClass(file); @@ -203,18 +220,17 @@ * @param file * @throws IOException */ - private void traceClass(File file) throws IOException + private void traceClass(File file, String message) throws IOException { - System.out.println("trace for "+file.getAbsolutePath()); + System.out.println("===== ("+message+") trace for "+file.getAbsolutePath()+" ====="); FileInputStream fis = null; try { fis = new FileInputStream(file); ClassReader cr = new ClassReader(fis); - TraceClassVisitor tcv = new TraceClassVisitor(new PrintWriter(System.out)); - cr.accept(tcv, - AbstractVisitor.getDefaultAttributes(), false); + TraceClassVisitor tcv = new TraceClassVisitor(null, new PrintWriter(System.out)); + cr.accept(tcv, Attributes.getDefaultAttributes(), true); } finally { @@ -223,16 +239,21 @@ fis.close(); } } + System.out.println("----- end trace -----"); } private void addAnnotation(String fileName, InputStream inputClass, OutputStream outputClass) throws BuildException { ClassWriter cw = new ClassWriter(false); try { ClassReader cr = new ClassReader(inputClass); - cr.accept(new MarkerClassVisitor(cw), AbstractVisitor.getDefaultAttributes(), false); + cr.accept(new MarkerClassVisitor(cw), + Attributes.getDefaultAttributes(), + true); byte[] b = cw.toByteArray(); + outputClass.write(b); } catch (Exception ex) { + ex.printStackTrace(); throw new BuildException("Unable to load class in file "+fileName, ex); } } @@ -243,16 +264,18 @@ super(cv); } + @Override public void visit(int version, int access, String name, - String superName, String sourceFile, String[] interfaces) { - super.visit(org.objectweb.asm.Constants.V1_5, access, name, superName, - sourceFile, interfaces); + String superName, String[] interfaces, String sourceFile) { + super.visit(org.objectweb.asm.Constants.V1_5, access, + name, superName, interfaces, sourceFile); } @SuppressWarnings("unchecked") public void visitEnd() { String t = Type.getDescriptor(SharedStatics.class); Annotation ann = new Annotation(t); + ann.add("name", ""); RuntimeVisibleAnnotations attr = new RuntimeVisibleAnnotations(); attr.annotations.add(ann); Modified: trunk/core/src/openjdk/sun/sun/misc/SharedSecrets.java =================================================================== --- trunk/core/src/openjdk/sun/sun/misc/SharedSecrets.java 2007-09-14 11:30:08 UTC (rev 3497) +++ trunk/core/src/openjdk/sun/sun/misc/SharedSecrets.java 2007-09-15 00:33:44 UTC (rev 3498) @@ -39,7 +39,6 @@ This framework avoids the primary disadvantage of using reflection for this purpose, namely the loss of compile-time checking. */ -@SharedStatics public class SharedSecrets { private static final Unsafe unsafe = Unsafe.getUnsafe(); private static JavaUtilJarAccess javaUtilJarAccess; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |