Commit 8eaf2437 authored by ebruneton's avatar ebruneton

merge with MUSTANG_SUPPORT branch

parent 7aad9cd9
......@@ -13,7 +13,6 @@
<classpathentry kind="src" path="examples/jbfc/src"/>
<classpathentry kind="src" path="examples/xml"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="test/lib/bcel.jar"/>
<classpathentry kind="lib" path="test/lib/javassist.jar"/>
<classpathentry kind="lib" path="test/lib/jd.xslt-1.5.5.jar"/>
<classpathentry kind="lib" path="test/lib/saxon7.jar"/>
......@@ -21,5 +20,7 @@
<classpathentry kind="lib" path="test/lib/xalan-2.6.0.jar"/>
<classpathentry sourcepath="ECLIPSE_HOME/plugins/org.eclipse.jdt.source_3.0.0/src/org.junit_3.8.1/junitsrc.zip" kind="var" path="JUNIT_HOME/junit.jar"/>
<classpathentry kind="lib" path="test/lib/janino-2.3.4.jar"/>
<classpathentry kind="lib" path="test/lib/aspectjweaver.jar"/>
<classpathentry kind="lib" path="test/lib/bcel-5.1.jar"/>
<classpathentry kind="output" path="output/eclipse"/>
</classpath>
#Fri Jan 06 15:15:38 EST 2006
#Sun Apr 09 11:53:48 CEST 2006
eclipse.preferences.version=1
org.eclipse.jdt.core.codeComplete.argumentPrefixes=
org.eclipse.jdt.core.codeComplete.argumentSuffixes=
org.eclipse.jdt.core.codeComplete.fieldPrefixes=
org.eclipse.jdt.core.codeComplete.fieldSuffixes=
org.eclipse.jdt.core.codeComplete.localPrefixes=
org.eclipse.jdt.core.codeComplete.localSuffixes=
org.eclipse.jdt.core.codeComplete.staticFieldPrefixes=
org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
......@@ -16,6 +8,7 @@ org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
org.eclipse.jdt.core.compiler.problem.deprecation=warning
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
......@@ -110,6 +103,7 @@ org.eclipse.jdt.core.formatter.compact_else_if=true
org.eclipse.jdt.core.formatter.continuation_indentation=2
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=1
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
......@@ -128,6 +122,7 @@ org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_ini
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
......
#Fri Jan 06 15:15:38 EST 2006
#Thu Apr 06 21:30:07 CEST 2006
comment_clear_blank_lines=false
comment_format_comments=true
comment_format_header=false
......@@ -10,11 +10,4 @@ comment_line_length=80
comment_new_line_for_parameter=false
comment_separate_root_tags=true
eclipse.preferences.version=1
formatter_settings_version=9
internal.default.compliance=default
org.eclipse.jdt.ui.exception.name=ex
org.eclipse.jdt.ui.gettersetter.use.is=true
org.eclipse.jdt.ui.javadoc=false
org.eclipse.jdt.ui.keywordthis=true
org.eclipse.jdt.ui.overrideannotation=false
org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\r\n * @return the ${bare_field_name}\r\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\r\n * @param ${param} the ${bare_field_name} to set\r\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment"></template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * @author ${user}\r\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\r\n * \r\n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\r\n * ${see_to_overridden}\r\n */</template><template autoinsert\="false" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">/***\r\n * ASM\: a very small and fast Java bytecode manipulation framework\r\n * Copyright (c) 2000-2005 INRIA, France Telecom\r\n * All rights reserved.\r\n *\r\n * Redistribution and use in source and binary forms, with or without\r\n * modification, are permitted provided that the following conditions\r\n * are met\:\r\n * 1. Redistributions of source code must retain the above copyright\r\n * notice, this list of conditions and the following disclaimer.\r\n * 2. Redistributions in binary form must reproduce the above copyright\r\n * notice, this list of conditions and the following disclaimer in the\r\n * documentation and/or other materials provided with the distribution.\r\n * 3. Neither the name of the copyright holders nor the names of its\r\n * contributors may be used to endorse or promote products derived from\r\n * this software without specific prior written permission.\r\n *\r\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\r\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\r\n * THE POSSIBILITY OF SUCH DAMAGE.\r\n */\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\r\nlogger.error( ${exception_var});</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method ${enclosing_method}\r\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\r\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
formatter_settings_version=10
......@@ -15,3 +15,4 @@ It contains(*) the following items:
- web: source of the web site of the product.
(*) some items may not be present, depending on the product.
......@@ -7,6 +7,7 @@
<jar jarfile="${out.dist.lib}/all/${ant.project.name}-${product.artifact}.jar"
basedir="${out.build}">
<include name="org/objectweb/asm/**/*.class"/>
<exclude name="org/objectweb/asm/optimizer/*.class"/>
<manifest>
<attribute name="Implementation-Title" value="ASM all classes"/>
<attribute name="Implementation-Version" value="${product.artifact}"/>
......
<project name="asm-attrs" default="dist">
<target name="dist" depends="build-jar,build-snapshot"/>
<target name="build-jar">
<jar jarfile="${out.dist.lib}/${ant.project.name}-${product.artifact}.jar"
basedir="${out.build}">
<include name="org/objectweb/asm/attrs/*.class"/>
<manifest>
<attribute name="Implementation-Title" value="ASM Attribute classes"/>
<attribute name="Implementation-Version" value="${product.artifact}"/>
<attribute name="Implementation-Vendor" value="France Telecom R&amp;D"/>
</manifest>
</jar>
<copy file="${archive}/maven-pom-template.xml" toFile="${out.dist.lib}/${ant.project.name}-${product.artifact}.pom"/>
<replace file="${out.dist.lib}/${ant.project.name}-${product.artifact}.pom" token="@product.name@" value="${ant.project.name}"/>
<replace file="${out.dist.lib}/${ant.project.name}-${product.artifact}.pom" token="@product.artifact@" value="${product.artifact}"/>
</target>
<target name="build-snapshot" if="product.snapshot">
<copy file="${out.dist.lib}/${ant.project.name}-${product.artifact}.jar" toFile="${out.dist.lib}/${ant.project.name}-SNAPSHOT.jar"/>
<copy file="${out.dist.lib}/${ant.project.name}-${product.artifact}.pom" toFile="${out.dist.lib}/${ant.project.name}-SNAPSHOT.pom"/>
<echo file="${out.dist.lib}/${ant.project.name}-snapshot-version" message="${product.build.time}"/>
</target>
</project>
......@@ -3,10 +3,16 @@
objectweb.ant.tasks.path config/ow_util_ant_tasks.jar
bcel.path test/lib/bcel.jar
bcel.path test/lib/bcel-5.1.jar
aspectj.path test/lib/aspectjweaver.jar
serp.path test/lib/serp.jar
javassist.path test/lib/javassist.jar
janino.path test/lib/janino-2.3.4.jar
cobertura.path test/lib/cobertura-1.8.jar;test/lib/jakarta-oro-2.0.8.jar;test/lib/log4j-1.2.9.jar;test/lib/asm-2.2.1.jar
cobertura.runtime.path test/lib/cobertura-1.8.jar
\ No newline at end of file
......@@ -31,10 +31,10 @@
# Some information about the product
product.name asm
product.version 2.2.2
product.version 3.0_beta2
# product.snapshot yes
plugin.version 2.2.2
plugin.version 3.0.0.beta2
###############################################################################
......@@ -58,11 +58,16 @@ build.compiler modern
# TESTS (PERFORMANCE COMPARISONS WITH BCEL AND SERP)
###############################################################################
# Class path for the BCEL library (version 5.0)
# Class path for the BCEL library (version 5.1)
# See http://jakarta.apache.org/bcel
# bcel.path bcel.jar
# Class path for the AspectJ library that contains the modified BCEL version
# (version 1.5) See http://www.eclipse.org/aspectj
# aspectj.path aspectjweaver.jar
# Class path for the SERP library (version 1.4.2)
# See http://serp.sourceforge.net
......@@ -78,6 +83,11 @@ build.compiler modern
# janino.path janino.jar
# Class paths for Cobertura (version 1.7)
# corbertura.path cobertura.jar
# cobertura.runtime.path cobertura.jar
###############################################################################
# DOCUMENTATION
###############################################################################
......
......@@ -47,7 +47,7 @@
<property name="examples.common" value="${examples}/common"/>
<property name="config" value="${basedir}/config"/>
<property name="archive" value="${basedir}/archive"/>
<property name="out" value="${basedir}/output"/>
<property name="out.build" value="${out}/build"/>
<property name="out.instr" value="${out}/instr"/>
......@@ -92,22 +92,15 @@
<target name="init" depends="properties,check">
<path id="classpath">
<path id="classpath">
<pathelement location="${out.build}"/>
</path>
<path id="cobertura.classpath">
<fileset dir="test/lib">
<include name="cobertura-1.7.jar"/>
<include name="log4j-1.2.9.jar"/>
<include name="jakarta-oro-2.0.8.jar"/>
<include name="asm-2.1.jar"/>
<include name="ccl.jar"/>
<include name="javancss.jar"/>
</fileset>
<pathelement path="${cobertura.path}"/>
</path>
<taskdef name="multipleAnt"
<taskdef name="multipleAnt"
classname="org.objectweb.util.ant.MultipleAnt"
classpath="${objectweb.ant.tasks.path}"/>
......@@ -168,6 +161,9 @@
<condition property="classes" value="${out.build}/tmp">
<isset property="debug"/>
</condition>
<condition property="asm.test" value="${java.home}/lib/rt.jar,${out.test}/cases">
<not><isset property="asm.test"/></not>
</condition>
<ant antfile="${test}/build.xml" target="test" inheritRefs="true"/>
</target>
......@@ -181,23 +177,37 @@
</target>
<target name="coverage" depends="compile">
<delete file="cobertura.ser"/>
<delete dir="${out.instr}"/>
<delete file="cobertura.ser"/>
<delete dir="${out.instr}"/>
<cobertura-instrument todir="${out.instr}">
<ignore regex="org.apache.log4j.*"/>
<ignore regex="java.lang.Error"/>
<fileset dir="${out.build}/tmp">
<include name="**/*.class"/>
<exclude name="**/optimizer/*.class" />
<exclude name="**/optimizer/*.class"/>
<exclude name="**/xml/Processor*.class"/>
<exclude name="**/*Test*.class" />
</fileset>
</cobertura-instrument>
<copy todir="${out.instr}" preservelastmodified="yes">
<fileset dir="${out.build}/tmp"/>
</copy>
<property name="classes" value="${out.instr}"/>
<property name="coverage" value="yes"/>
<property name="classes" value="${out.instr}"/>
<property name="asm.test.class" value="pkg"/>
<condition property="asm.test" value="${out.test}/cases">
<not><isset property="asm.test"/></not>
</condition>
<condition property="test.type" value="conform">
<not><isset property="test.type"/></not>
</condition>
<ant antfile="${test}/build.xml" target="test" inheritRefs="true"/>
</target>
<target name="coverage.check" depends="init">
<cobertura-check branchrate="100" linerate="100">
</cobertura-check>
</target>
<target name="coverage.report" depends="init">
<cobertura-report destdir="${out}/coverage" srcdir="${src}" format="xml"/>
<cobertura-report destdir="${out}/coverage">
......@@ -294,38 +304,15 @@
</copy>
</target>
<target name="eclipse.generate" depends="dist.version">
<echo file="${basedir}/plugin.xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<plugin id="org.objectweb.asm" name="ASM Framework" version="${plugin.artifact}" provider-name="ObjectWeb.org">
<runtime>
<library name="output/dist/lib/asm-${product.artifact}.jar">
<export name="*"/>
</library>
<library name="output/dist/lib/asm-tree-${product.artifact}.jar">
<export name="*"/>
</library>
<library name="output/dist/lib/asm-analysis-${product.artifact}.jar">
<export name="*"/>
</library>
<library name="output/dist/lib/asm-commons-${product.artifact}.jar">
<export name="*"/>
</library>
<library name="output/dist/lib/asm-attrs-${product.artifact}.jar">
<export name="*"/>
</library>
<library name="output/dist/lib/asm-util-${product.artifact}.jar">
<export name="*"/>
</library>
</runtime>
</plugin>]]></echo>
<!--
<target name="eclipse.generate" depends="dist.version">
</target>
<target name="eclipse.plugin" depends="jar,eclipse.generate">
<zip zipfile="${out}/org.objectweb.asm_${plugin.artifact}.jar">
<jar zipfile="${out}/org.objectweb.asm_${plugin.artifact}.jar">
<zipfileset dir="${basedir}">
<include name="plugin.xml"/>
<include name="META-INF/MANIFEST.MF"/>
<include name="**/asm-${product.artifact}.jar"/>
<include name="**/asm-tree-${product.artifact}.jar"/>
<include name="**/asm-analysis-${product.artifact}.jar"/>
......@@ -333,7 +320,30 @@
<include name="**/asm-commons-${product.artifact}.jar"/>
<include name="**/asm-attrs-${product.artifact}.jar"/>
</zipfileset>
</zip>
<manifest>
<attribute name="Bundle-ManifestVersion" value="2"/>
<attribute name="Bundle-Name" value="ASM Framework"/>
<attribute name="Bundle-SymbolicName" value="org.objectweb.asm;singleton:=true"/>
<attribute name="Bundle-Version" value="${plugin.artifact}"/>
<attribute name="Bundle-ClassPath" value="output/dist/lib/asm-${product.artifact}.jar,
output/dist/lib/asm-tree-${product.artifact}.jar,
output/dist/lib/asm-analysis-${product.artifact}.jar,
output/dist/lib/asm-commons-${product.artifact}.jar,
output/dist/lib/asm-attrs-${product.artifact}.jar,
output/dist/lib/asm-util-${product.artifact}.jar"/>
<attribute name="Bundle-Vendor" value="ObjectWeb.org"/>
<attribute name="Bundle-Localization" value="plugin"/>
<attribute name="Export-Package" value="org.objectweb.asm,
org.objectweb.asm.attrs,
org.objectweb.asm.commons,
org.objectweb.asm.signature,
org.objectweb.asm.tree,
org.objectweb.asm.tree.analysis,
org.objectweb.asm.util,
org.objectweb.asm.xml"/>
<attribute name="Eclipse-AutoStart" value="true"/>
</manifest>
</jar>
</target>
<target name="eclipse.feature" depends="eclipse.plugin">
......@@ -400,6 +410,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
<zipfileset dir="${out}" includes="org.objectweb.asm_${plugin.artifact}.jar" prefix="plugins"/>
</zip>
</target>
-->
<target name="dist" depends="jar,jdoc,examples">
<zip zipFile="${out.dist}/src.zip" basedir="${src}" excludes="**/optimizer/**/*"/>
......
......@@ -67,9 +67,9 @@ public class Adapt extends ClassLoader {
// adapts the class on the fly
try {
ClassReader cr = new ClassReader(is);
ClassWriter cw = new ClassWriter(false);
ClassWriter cw = new ClassWriter(0);
ClassVisitor cv = new TraceFieldClassAdapter(cw);
cr.accept(cv, false);
cr.accept(cv, 0);
b = cw.toByteArray();
} catch (Exception e) {
throw new ClassNotFoundException(name, e);
......
......@@ -37,7 +37,7 @@ public class ArraySet {
private int size;
public boolean contains(int v) {
public boolean contains(final int v) {
for (int i = 0; i < size; ++i) {
if (values[i] == v) {
return true;
......@@ -46,7 +46,7 @@ public class ArraySet {
return false;
}
public void add(int v) {
public void add(final int v) {
if (!contains(v)) {
if (size == values.length) {
System.err.println("[enlarge]");
......@@ -60,7 +60,7 @@ public class ArraySet {
}
}
public void remove(int v) {
public void remove(final int v) {
int i = 0;
int j = 0;
while (i < size) {
......@@ -75,7 +75,7 @@ public class ArraySet {
// test method
public static void main(String[] args) {
public static void main(final String[] args) {
ArraySet s = new ArraySet();
System.err.println("add 1");
s.add(1);
......
......@@ -41,8 +41,8 @@ import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.VarInsnNode;
import org.objectweb.asm.tree.analysis.Analyzer;
import org.objectweb.asm.tree.analysis.BasicVerifier;
import org.objectweb.asm.tree.analysis.DataflowInterpreter;
import org.objectweb.asm.tree.analysis.DataflowValue;
import org.objectweb.asm.tree.analysis.SourceInterpreter;
import org.objectweb.asm.tree.analysis.SourceValue;
import org.objectweb.asm.tree.analysis.Frame;
import org.objectweb.asm.util.TraceMethodVisitor;
......@@ -51,10 +51,10 @@ import org.objectweb.asm.util.TraceMethodVisitor;
*/
public class Analysis implements Opcodes {
public static void main(String[] args) throws Exception {
public static void main(final String[] args) throws Exception {
ClassReader cr = new ClassReader("Analysis");
ClassNode cn = new ClassNode();
cr.accept(cn, true);
cr.accept(cn, ClassReader.SKIP_DEBUG);
List methods = cn.methods;
for (int i = 0; i < methods.size(); ++i) {
......@@ -104,8 +104,10 @@ public class Analysis implements Opcodes {
* least one xLOAD corresponding instruction in their successor instructions
* (in the control flow graph).
*/
public static boolean analyze(ClassNode c, MethodNode m) throws Exception {
Analyzer a = new Analyzer(new DataflowInterpreter());
public static boolean analyze(final ClassNode c, final MethodNode m)
throws Exception
{
Analyzer a = new Analyzer(new SourceInterpreter());
Frame[] frames = a.analyze(c.name, m);
// for each xLOAD instruction, we find the xSTORE instructions that can
......@@ -116,12 +118,12 @@ public class Analysis implements Opcodes {
Object insn = m.instructions.get(i);
int opcode = ((AbstractInsnNode) insn).getOpcode();
if ((opcode >= ILOAD && opcode <= ALOAD) || opcode == IINC) {
int var = (opcode == IINC
int var = opcode == IINC
? ((IincInsnNode) insn).var
: ((VarInsnNode) insn).var);
: ((VarInsnNode) insn).var;
Frame f = frames[i];
if (f != null) {
Set s = ((DataflowValue) f.getLocal(var)).insns;
Set s = ((SourceValue) f.getLocal(var)).insns;
Iterator j = s.iterator();
while (j.hasNext()) {
insn = j.next();
......
......@@ -59,7 +59,7 @@ public class Annotations {
}
final String n = Annotations.class.getName();
final ClassWriter cw = new ClassWriter(true);
final ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
ClassReader cr = new ClassReader(n);
cr.accept(new ClassAdapter(cw) {
......@@ -78,7 +78,7 @@ public class Annotations {
exceptions);
return new MethodAdapter(v) {
private List params = new ArrayList();
private final List params = new ArrayList();
public AnnotationVisitor visitParameterAnnotation(
final int parameter,
......@@ -96,7 +96,7 @@ public class Annotations {
}
public void visitCode() {
int var = ((access & Opcodes.ACC_STATIC) == 0) ? 1 : 0;
int var = (access & Opcodes.ACC_STATIC) == 0 ? 1 : 0;
for (int p = 0; p < params.size(); ++p) {
int param = ((Integer) params.get(p)).intValue();
for (int i = 0; i < param; ++i) {
......@@ -121,7 +121,7 @@ public class Annotations {
}
};
}
}, false);
}, 0);
Class c = new ClassLoader() {
public Class loadClass(final String name)
......
......@@ -50,9 +50,9 @@ public class Attributes extends ClassLoader {
public static void main(final String args[]) throws Exception {
// loads the original class and adapts it
ClassReader cr = new ClassReader("CommentAttribute");
ClassWriter cw = new ClassWriter(false);
ClassWriter cw = new ClassWriter(0);
ClassVisitor cv = new AddCommentClassAdapter(cw);
cr.accept(cv, new Attribute[] { new CommentAttribute("") }, false);
cr.accept(cv, new Attribute[] { new CommentAttribute("") }, 0);
byte[] b = cw.toByteArray();
// stores the adapted class on disk
......@@ -63,7 +63,7 @@ public class Attributes extends ClassLoader {
// "disassembles" the adapted class
cr = new ClassReader(b);
cv = new TraceClassVisitor(new PrintWriter(System.out));
cr.accept(cv, new Attribute[] { new CommentAttribute("") }, false);
cr.accept(cv, new Attribute[] { new CommentAttribute("") }, 0);
}
}
......@@ -134,22 +134,22 @@ class CommentAttribute extends Attribute {
}
protected Attribute read(
ClassReader cr,
int off,
int len,
char[] buf,
int codeOff,
Label[] labels)
final ClassReader cr,
final int off,
final int len,
final char[] buf,
final int codeOff,
final Label[] labels)
{
return new CommentAttribute(cr.readUTF8(off, buf));
}
protected ByteVector write(
ClassWriter cw,
byte[] code,
int len,
int maxStack,
int maxLocals)
final ClassWriter cw,
final byte[] code,
final int len,
final int maxStack,
final int maxLocals)
{
return new ByteVector().putShort(cw.newUTF8(comment));
}
......
......@@ -39,7 +39,7 @@ import java.io.FileOutputStream;
*/
public class Compile extends ClassLoader {
public static void main(String[] args) throws Exception {
public static void main(final String[] args) throws Exception {
// creates the expression tree corresponding to
// exp(i) = i > 3 && 6 > i
Exp exp = new And(new GT(new Var(0), new Cst(3)), new GT(new Cst(6),
......@@ -72,10 +72,10 @@ abstract class Exp implements Opcodes {
* Returns the byte code of an Expression class corresponding to this
* expression.
*/
byte[] compile(String name) {
byte[] compile(final String name) {
// class header
String[] itfs = { Expression.class.getName() };
ClassWriter cw = new ClassWriter(true);
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
cw.visit(V1_1, ACC_PUBLIC, name, null, "java/lang/Object", itfs);
// default public constructor
......@@ -116,11 +116,11 @@ class Cst extends Exp {
int value;
Cst(int value) {
Cst(final int value) {
this.value = value;
}
void compile(MethodVisitor mv) {
void compile(final MethodVisitor mv) {
// pushes the constant's value onto the stack
mv.visitLdcInsn(new Integer(value));
}
......@@ -133,11 +133,11 @@ class Var extends Exp {
int index;
Var(int index) {
Var(final int index) {
this.index = index + 1;
}
void compile(MethodVisitor mv) {
void compile(final MethodVisitor mv) {
// pushes the 'index' local variable onto the stack
mv.visitVarInsn(ILOAD, index);
}
......@@ -152,7 +152,7 @@ abstract class BinaryExp extends Exp {
Exp e2;
BinaryExp(Exp e1, Exp e2) {
BinaryExp(final Exp e1, final Exp e2) {
this.e1 = e1;
this.e2 = e2;
}
......@@ -163,11 +163,11 @@ abstract class BinaryExp extends Exp {
*/
class Add extends BinaryExp {
Add(Exp e1, Exp e2) {
Add(final Exp e1, final Exp e2) {
super(e1, e2);
}
void compile(MethodVisitor mv) {
void compile(final MethodVisitor mv) {
// compiles e1, e2, and adds an instruction to add the two values
e1.compile(mv);
e2.compile(mv);
......@@ -180,11 +180,11 @@ class Add extends BinaryExp {
*/
class Mul extends BinaryExp {
Mul(Exp e1, Exp e2) {
Mul(final Exp e1, final Exp e2) {
super(e1, e2);
}
void compile(MethodVisitor mv) {
void compile(final MethodVisitor mv) {
// compiles e1, e2, and adds an instruction to multiply the two values
e1.compile(mv);
e2.compile(mv);
......@@ -197,11 +197,11 @@ class Mul extends BinaryExp {
*/
class GT extends BinaryExp {
GT(Exp e1, Exp e2) {
GT(final Exp e1, final Exp e2) {
super(e1, e2);
}
void compile(MethodVisitor mv) {
void compile(final MethodVisitor mv) {