rebuilt with java-gcj-compat support [release 2.2.3-3mamba;Sat Mar 26 2011]
This commit is contained in:
parent
8b8986f17c
commit
6ff9e79490
@ -1,2 +1,6 @@
|
||||
# objectweb-asm2
|
||||
|
||||
ASM is an all purpose Java bytecode manipulation and analysis framework. It can be used to modify existing classes or dynamically generate classes, directly in binary form. Provided common transformations and analysis algorithms allow to easily assemble custom complex transformations and code analysis tools.
|
||||
ASM offer similar functionality as other bytecode frameworks, but it is focused on simplicity of use and performance. Because it was designed and implemented to be as small and as fast as possible, it makes it very attractive for using in dynamic systems*.
|
||||
(*) ASM can of course be used in a static way too.
|
||||
|
||||
|
BIN
asm-eng.pdf
Normal file
BIN
asm-eng.pdf
Normal file
Binary file not shown.
14454
asm-guide.pdf
Normal file
14454
asm-guide.pdf
Normal file
File diff suppressed because one or more lines are too long
BIN
asm-transformations.pdf
Normal file
BIN
asm-transformations.pdf
Normal file
Binary file not shown.
698
faq.html
Normal file
698
faq.html
Normal file
@ -0,0 +1,698 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
|
||||
<meta content="en" http-equiv="Content-Language">
|
||||
<title>ASM - ASM FAQ</title>
|
||||
<meta name="Description" content="ASM is a very small and very fast Java bytecode manipulation framework.">
|
||||
<meta name="Keywords" content="ASM,bytecode,manipulation,Java,open,source,free,software,BSD">
|
||||
<meta name="Reply-to" content="webmaster@objectweb.org">
|
||||
<meta name="Owner" content="ObjectWeb">
|
||||
<meta name="Robots" content="index, follow">
|
||||
<meta content="asm-team" name="author">
|
||||
<meta content="asm-team@objectweb.org" name="email">
|
||||
<script src="../js/objectweb.js" type="text/javascript"></script>
|
||||
<link type="text/css" href="../common.css" rel="stylesheet" id="stylesheet">
|
||||
<link type="image/x-icon" href="../images/favicon.ico" rel="icon">
|
||||
<link type="image/x-icon" href="../images/favicon.ico" rel="shortcut icon">
|
||||
</head>
|
||||
<body marginheight="0" marginwidth="0" topmargin="0" leftmargin="0" onload="MM_preloadImages('../images/menu/boutonok2.gif','../images/menu/boutonsearch2.gif','../images/menu/boutonprint2.gif','../images/menu/boutonsubscribe2.gif')" bgcolor="#FFFFFF" class="bodyproject">
|
||||
<table cellpadding="0" cellspacing="0" width="100%" border="0">
|
||||
<tr>
|
||||
<td valign="top" width="245"><img alt=" " height="20" src="../images/pix.gif"></td><td width="100%" bgcolor="#E8EAF0" valign="bottom"> <a class="barre" href="http://consortium.objectweb.org/"> Consortium </a> <a class="barre" href="http://solutions.objectweb.org/"> Solutions </a> <a class="barre" href="http://middleware.objectweb.org/"> Middleware </a> <a class="barre" href="http://forge.objectweb.org/"> Forge </a> <a class="barre" href="http://myobjectweb.objectweb.org/"> MyObjectWeb </a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" width="245"><a href="http://www.objectweb.org/"><img alt="ObjectWeb Consortium" border="0" height="80" width="245" src="../images/logoow.gif"></a></td><td valign="top">
|
||||
<table cellpadding="0" cellspacing="0" width="100%" border="0">
|
||||
<tr>
|
||||
<td valign="top"><img alt=" " height="20" width="395" src="../images/pix.gif"></td><td valign="top" width="150"><img alt=" " height="20" width="150" src="../images/pix.gif"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<table cellpadding="5" cellspacing="0" border="0">
|
||||
<tr>
|
||||
<td valign="top"></td><td valign="top"></td><td valign="top"></td><td valign="top"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td><td style="line-height: 20px;" valign="top" width="150">
|
||||
<form action="">
|
||||
<table>
|
||||
<tr>
|
||||
<td><select onChange="MM_goToURL('parent',this.options[this.selectedIndex].value);return document.MM_returnValue" name="navigation"><option>Go to ObjectWeb...</option><option value="http://www.objectweb.org/">Home Page</option><option value="http://consortium.objectweb.org/">Consortium</option><option value="http://solutions.objectweb.org/">Solutions</option><option value="http://middleware.objectweb.org/">Middleware</option><option value="http://forge.objectweb.org/">Project Forge</option><option value="http://myobjectweb.objectweb.org/">My ObjectWeb</option></select></td><td><input alt="Submit" border="0" onmouseover="MM_swapImage('ok','','../images/menu/boutonok2.gif',1)" onmouseout="MM_swapImgRestore()" src="../images/menu/boutonok1.gif" id="ok" name="Ok" type="image"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<form target="_blank" action="http://www.google.com/custom" method="get">
|
||||
<input value="S:http://www.objectweb.org/;GL:0;AH:center;LH:81;L:http://www.objectweb.org/media/owlogos/ObjectWeb-small.gif;LW:236;AWFID:48faba182d01f379;" name="cof" type="hidden"><input value="objectweb.org;mail-archive.objectweb.org;www.enhydra.org" name="domains" type="hidden"><input value="objectweb.org;www.enhydra.org" name="sitesearch" type="hidden">
|
||||
<table rowspan="0" colspan="0">
|
||||
<tr>
|
||||
<td><input onblur="if (this.value=='') this.value='search'" onfocus="this.value=''" value="" maxlength="255" size="10" name="q" type="text"></td><td><input alt="Submit" onmouseover="MM_swapImage('search','','../images/menu/boutonsearch2.gif',1)" onmouseout="MM_swapImgRestore()" src="../images/menu/boutonsearch1.gif" id="search" name="sa" type="image"></td><td><a alt="Submit" onmouseover="MM_swapImage('print','','../images/menu/boutonprint2.gif',1)" onmouseout="MM_swapImgRestore()" target="_blank" href="faq_print.html"><img id="print" border="0" height="20" width="20" name="print" alt="Print" src="../images/menu/boutonprint1.gif"></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
<p class="glose">
|
||||
<strong><a target="_blank" class="lienglose" href="http://www.objectweb.org/search.html">Advanced</a></strong> - Powered by Google</p>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table cellpadding="0" cellspacing="0" border="0" width="100%" summary="">
|
||||
<tr>
|
||||
<td valign="top" width="20"><img alt=" " height="1" width="20" src="../images/pix.gif"></td><td valign="top" width="160"><img alt=" " height="1" width="160" src="../images/pix.gif"><br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<p style="font-size: 16px; font-weight: bold; color: #433C7B;">ASM</p>
|
||||
<p>
|
||||
<span class="menutitre">Project Links</span>
|
||||
<br>
|
||||
· <a class="menu" target="_self" href="../index.html">Home</a>
|
||||
<br>
|
||||
· <a class="menu" target="_self" href="../download/index.html">Download</a>
|
||||
<br>
|
||||
· <a class="menu" target="_self" href="../eclipse/index.html">Eclipse plugin</a>
|
||||
<br>
|
||||
· <a class="menu" target="_self" href="http://download.forge.objectweb.org/asm/asm-guide.pdf">User Guide</a>
|
||||
<br>
|
||||
· <a class="menu" target="_self" href="http://mail.ow2.org/wws/info/asm">Mailing Lists</a>
|
||||
<br>
|
||||
· <a class="menu" target="_self" href="../license.html">License</a>
|
||||
<br>
|
||||
· <a class="menu" target="_self" href="../history.html">History</a>
|
||||
<br>
|
||||
</p>
|
||||
<p>
|
||||
<span class="menutitre">Developers' Corner</span>
|
||||
<br>
|
||||
· <a class="menu" target="_self" href="http://forge.objectweb.org/projects/asm/">ObjectWeb Forge Site</a>
|
||||
<br>
|
||||
· <a class="menu" target="_self" href="http://forge.objectweb.org/plugins/scmsvn/index.php?group_id=23">SVN Repository</a>
|
||||
<br>
|
||||
· <a class="menu" target="_self" href="http://forge.objectweb.org/cvs/?group_id=23">CVS Repository (old)</a>
|
||||
<br>
|
||||
· <a class="menu" target="_self" href="http://forge.objectweb.org/tracker/?group_id=23">Issue Tracker</a>
|
||||
<br>
|
||||
· <a class="menu" target="_self" href="../doc/developer-guide.html">Developer Guide</a>
|
||||
<br>
|
||||
</p>
|
||||
<p>
|
||||
<span class="menutitre">About</span>
|
||||
<br>
|
||||
· <a class="menu" target="_self" href="../users.html">Users</a>
|
||||
<br>
|
||||
· <a class="menu" target="_self" href="../team.html">Team</a>
|
||||
<br>
|
||||
· <a class="menu" target="_self" href="mailto:asm-team@objectweb.org">Contacts</a>
|
||||
<br>
|
||||
</p>
|
||||
</td><td align="left" width="100%" valign="top">
|
||||
<h1>Frequently Asked Questions</h1>
|
||||
|
||||
<p>Here are some frequently asked questions about ASM, gathered by
|
||||
<a href="mailto:m.proctor@bigfoot.com">Mark Proctor</a>.</p>
|
||||
|
||||
<ul>
|
||||
|
||||
<li>
|
||||
<a href="#Q0">0. How do I start using ASM?</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#Q1">1. How do I remove a method/field?</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#Q2">2. How do I replace a method/field? I end up with duplicated members!</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#Q3">3. How do I make ASM calculate visitMaxs for me?</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#Q4">4. Why do I get the [xxx] verifier error?"</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#Q5">5. How do I add my bytecode class to the system class loader?</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#Q6">6. How do I rename my class?</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#Q7">7. How do method descriptors work?</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#Q8">8. How can ASM help me create my descriptor types?</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#Q9">9. How do I generate Setters and Getters for my class?</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#Q10">10. How do I get the bytecode of an existing class?</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#Q11">11. How do I generate [some Java code] with ASM?</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#Q12">12. How does the [xxx] bytecode instruction work?</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#Q13">13. Is ASM thread safe?</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#Q14">14. What is the earliest JDK required to use ASM?</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="#Q15">15. How to resolve conflicts between different ASM API
|
||||
versions available in a global classpath or within the same ClassLoader?</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>
|
||||
<a name="Q0"></a>0. How do I start using ASM?</h3>
|
||||
|
||||
|
||||
<p>If you want to use ASM to generate classes from scratch, write a Java source
|
||||
file that is representative of the classes you want to generate, compile it(*), and
|
||||
then run the <a href="#Q10">ASMifier</a> on the compiled class to see the Java source code that
|
||||
generates this class with ASM. If you are using Eclipse it is even easier,
|
||||
thanks to the <a href="../eclipse/bco/index.html">Bytecode Outline</a> plugin.</p>
|
||||
|
||||
|
||||
<p>If you want to use ASM to transform classes, write two Java source files -
|
||||
first with and second without features that has to be added or removed and try
|
||||
to keep other differences as minimal as you can, compile them(*), and then run the
|
||||
<a href="#Q10">ASMifier</a> on both of them. Then compare the results with some visual diff tool.
|
||||
If you are using Eclipse it is even easier, thanks to the compare tool of the
|
||||
<a href="../eclipse/bco/index.html">Bytecode Outline</a> plugin.</p>
|
||||
|
||||
|
||||
<p>(*) Note that javac may produce different code for different -target,
|
||||
so you'll have to compile for your target environment, repeat that
|
||||
excercise for all required target's or use the earliest bytecode version
|
||||
if possible.</p>
|
||||
|
||||
|
||||
<h3>
|
||||
<a name="Q1"></a>1. How do I remove a method/field?</h3>
|
||||
|
||||
|
||||
<p>Use the ClassAdapter and return nothing:</p>
|
||||
|
||||
<pre> public FieldVisitor visitField (String name, ...) {
|
||||
if (removeField(name)) {
|
||||
// do nothing, in order to remove this field
|
||||
return null;
|
||||
} else {
|
||||
// make the next visitor visit this field, in order to keep it
|
||||
return super.visitField(name, ...);
|
||||
}
|
||||
}</pre>
|
||||
|
||||
|
||||
<h3>
|
||||
<a name="Q2"></a>2. How do I replace a method/field? I end up with duplicated members!</h3>
|
||||
|
||||
|
||||
<p>You must either return the replacement method/field when you visit the original one using the
|
||||
ClassAdapter, or you must first remove the original method/field in the ClassAdapter (see
|
||||
<a href="#Q1">"1. How do I remove a method/field?"</a>), and then add the new method/field
|
||||
by calling a visit method on the ClassWriter.</p>
|
||||
|
||||
|
||||
<h3>
|
||||
<a name="Q3"></a>3. How do I make ASM calculate visitMaxs for me?</h3>
|
||||
|
||||
|
||||
<p>When calling the constructor for ClassWriter pass true. You must also
|
||||
still include the visitMaxs instruction, but the values you give are
|
||||
ignored, so visitMaxs(0,0) is fine.</p>
|
||||
|
||||
|
||||
<h3>
|
||||
<a name="Q4"></a>4. Why do I get the [xxx] verifier error?</h3>
|
||||
|
||||
|
||||
<p>If the message given by the JVM class verifier does not help you, you can
|
||||
use the verifier provided by ASM. For example, if you use a wrong constant when
|
||||
making "return" on a method, or if you do not use the appropriate LOAD or STORE
|
||||
instruction, depending on the local variable type, the JVM class verifier gives
|
||||
a "Register x contains wrong type" or "Expecting to find x on stack" error which
|
||||
does not say anything about the instruction that caused the error. In this case
|
||||
you can use the class verifier provided by ASM (asm-attrs.jar is needed with
|
||||
ASM 2.x only):</p>
|
||||
|
||||
|
||||
<p>
|
||||
<code>java -cp "asm.jar;asm-tree.jar;asm-analysis.jar;asm-attrs.jar;asm-util.jar"
|
||||
org.objectweb.asm.util.CheckClassAdapter org/domain/package/YourClass.class</code>
|
||||
</p>
|
||||
|
||||
|
||||
<p>For example, in the helloworld example in the ASM distribution, if you replace
|
||||
visitLdcInsn("Hello world!") with visitLdcInsn(new Integer(1234)) you get the following
|
||||
error message when the generated class is verified as above:</p>
|
||||
|
||||
|
||||
<pre>org.objectweb.asm.tree.analysis.AnalyzerException: Error at instruction 2: Argument 1: expected Ljava/lang/String;, but found I
|
||||
at org.objectweb.asm.tree.analysis.Analyzer.analyze(Unknown Source)
|
||||
at org.objectweb.asm.util.CheckClassAdapter.verify(Unknown Source)
|
||||
at org.objectweb.asm.util.CheckClassAdapter.main(Unknown Source)
|
||||
...
|
||||
main([Ljava/lang/String;)V
|
||||
00000 String . : : GETSTATIC java/lang/System.out : Ljava/io/PrintStream;
|
||||
00001 String . : PrintStream : LDC 1234
|
||||
00002 String . : PrintStream I : INVOKEVIRTUAL java/io/PrintStream.println (Ljava/lang/String;)V
|
||||
00003 ? : RETURN</pre>
|
||||
|
||||
|
||||
<p>This shows that the error comes from instruction 2 in method main. The instruction list
|
||||
shows that this instruction is INVOKEVIRTUAL. It also shows the types of the local variables
|
||||
and of the operand stack values just before this instruction will be executed (here local
|
||||
variable 0 contains a String, local variable 1 is not initialized, and the stack contains
|
||||
a PrintStream and an int - I stands for int, as in type descriptors). As explained in the
|
||||
error message, the println method called by
|
||||
INVOKEVIRTUAL expects a String as first argument, but the stack value corresponding to this
|
||||
argument is an int. Then either the INVOKEVIRTUAL instruction is wrong, or the instruction
|
||||
that pushed the integer is wrong.</p>
|
||||
|
||||
|
||||
<p>If your class is so "corrupted" that you cannot read it with a ClassReader,
|
||||
try to generate it by using a CheckClassAdapter in front of a ClassWriter:</p>
|
||||
|
||||
<pre> ClassWriter cw = new ClassWriter(true);
|
||||
ClassVisitor cv = new CheckClassAdapter(cw);
|
||||
// generate your class here:
|
||||
cv.visit(...);
|
||||
...</pre>
|
||||
|
||||
<p>You will probably get an exception which will indicate why your generated class
|
||||
is incorrect. For example, if you forget to call visit(...) (which can happen if you
|
||||
forget to call super.visit(...) in a class adapter), the generated class
|
||||
contains an invalid constant pool index, and ClassReader is unable to read it. If
|
||||
you generate your class by using a CheckClassAdapter, as above, you get an
|
||||
exception "Cannot visit member before visit has been called.", which shows that
|
||||
you forgot to call the visit method.</p>
|
||||
|
||||
|
||||
<h3>
|
||||
<a name="Q5"></a>5. How do I add my bytecode class to the system class loader?</h3>
|
||||
|
||||
|
||||
<p>You must first have the security to do this, as defined in the policy
|
||||
file - there are no security restrictions as default for a standard java
|
||||
install. Use ClassLoader.defineClass, this however is a "protected" method, so
|
||||
you must use reflection to gain access to it:</p>
|
||||
|
||||
<pre> private Class loadClass (byte[] b) {
|
||||
//override classDefine (as it is protected) and define the class.
|
||||
Class clazz = null;
|
||||
try {
|
||||
ClassLoader loader = ClassLoader.getSystemClassLoader();
|
||||
Class cls = Class.forName("java.lang.ClassLoader");
|
||||
java.lang.reflect.Method method =
|
||||
cls.getDeclaredMethod("defineClass", new Class[] { String.class, byte[].class, int.class, int.class });
|
||||
|
||||
// protected method invocaton
|
||||
method.setAccessible(true);
|
||||
try {
|
||||
Object[] args = new Object[] { className, b, new Integer(0), new Integer(b.length)};
|
||||
clazz = (Class) method.invoke(loader, args);
|
||||
} finally {
|
||||
method.setAccessible(false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
return clazz;
|
||||
}</pre>
|
||||
|
||||
<p>Alternatively you can create your own ClassLoader by extending the
|
||||
existing class loader (example needed here).</p>
|
||||
|
||||
|
||||
|
||||
<h3>
|
||||
<a name="Q6"></a>6. How do I rename my class?</h3>
|
||||
|
||||
|
||||
<p>It is not enough to rename just the class, you must also rename all the
|
||||
references to class members using the MethodAdapter.</p>
|
||||
|
||||
<pre>class ClassRenamer extends ClassAdapter implements Opcodes {
|
||||
|
||||
private Set oldNames;
|
||||
private final String newName;
|
||||
|
||||
public ClassRenamer(ClassVisitor cv, Set oldNames, String newName) {
|
||||
super(cv);
|
||||
this.oldNames = oldNames;
|
||||
this.newName = newName;
|
||||
}
|
||||
|
||||
public void visit (int version, int access, String name, String signature, String superName, String[] interfaces) {
|
||||
oldNames.add(name);
|
||||
cv.visit(version, ACC_PUBLIC, newName, signature, superName, interfaces);
|
||||
}
|
||||
|
||||
public MethodVisitor visitMethod (int access, String name, String desc, String signature, String[] exceptions) {
|
||||
MethodVisitor mv = cv.visitMethod(access, name, fixDesc(desc), fix(signature), exceptions);
|
||||
if (mv != null && (access & ACC_ABSTRACT) == 0) {
|
||||
mv = new MethodRenamer(mv);
|
||||
}
|
||||
return mv;
|
||||
}
|
||||
|
||||
class MethodRenamer extends MethodAdapter {
|
||||
|
||||
public MethodRenamer (final MethodVisitor mv) {
|
||||
super(mv);
|
||||
}
|
||||
|
||||
public void visitTypeInsn (int i, String s) {
|
||||
if (oldNames.contains(s)) {
|
||||
s = newName;
|
||||
}
|
||||
mv.visitTypeInsn(i, s);
|
||||
}
|
||||
|
||||
public void visitFieldInsn (int opcode, String owner, String name, String desc) {
|
||||
if (oldNames.contains(owner)) {
|
||||
mv.visitFieldInsn(opcode, newName, name, fix(desc));
|
||||
} else {
|
||||
mv.visitFieldInsn(opcode, owner, name, fix(desc));
|
||||
}
|
||||
}
|
||||
|
||||
public void visitMethodInsn (int opcode, String owner, String name, String desc) {
|
||||
if (oldNames.contains(owner)) {
|
||||
mv.visitMethodInsn(opcode, newName, name, fix(desc));
|
||||
} else {
|
||||
mv.visitMethodInsn(opcode, owner, name, fix(desc));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String fix (String s) {
|
||||
if (s != null) {
|
||||
Iterator it = oldNames.iterator();
|
||||
String name;
|
||||
while (it.hasNext()) {
|
||||
name = (String) it.next();
|
||||
if (s.indexOf(name) != -1) {
|
||||
s = desc.replaceAll(name, newName);
|
||||
}
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}</pre>
|
||||
|
||||
|
||||
|
||||
<h3>
|
||||
<a name="Q7"></a>7. How do method descriptors work?</h3>
|
||||
|
||||
|
||||
<p>To understand this best it's good to read the source code of Type.java.
|
||||
Here is a quick overview:</p>
|
||||
|
||||
<ul>
|
||||
|
||||
<li>Primitive representations:
|
||||
<ul>
|
||||
|
||||
<li>'V' - void</li>
|
||||
|
||||
<li>'Z' - boolean</li>
|
||||
|
||||
<li>'C' - char</li>
|
||||
|
||||
<li>'B' - byte</li>
|
||||
|
||||
<li>'S' - short</li>
|
||||
|
||||
<li>'I' - int</li>
|
||||
|
||||
<li>'F' - float</li>
|
||||
|
||||
<li>'J' - long</li>
|
||||
|
||||
<li>'D' - double</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li>Class representations:
|
||||
<ul>
|
||||
|
||||
<li>L<class>;</li>
|
||||
|
||||
<li>Ljava/io/ObjectOutput;</li>
|
||||
|
||||
<li>Ljava/lang/String;</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
<p>Examples:</p>
|
||||
|
||||
<ul>
|
||||
|
||||
<li>public void method()
|
||||
<ul>
|
||||
<li>
|
||||
<code>cw.visitMethod(ACC_PUBLIC, methodName, "()V", null, null);</code>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li>public void method(String s, int i)
|
||||
<ul>
|
||||
<li>
|
||||
<code>cw.visitMethod(ACC_PUBLIC, methodName, "(Ljava/lang/String;I)V", null, null);</code>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li>public String method(String s, int i, boolan flag)
|
||||
<ul>
|
||||
<li>
|
||||
<code>cw.visitMethod(ACC_PUBLIC, methodName, "(Ljava/lang/String;IZ)Ljava/lang/String;", null, null);</code>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
<h3>
|
||||
<a name="Q8"></a>8. How can ASM help me create my descriptor types?</h3>
|
||||
|
||||
|
||||
<p>Types.java provides the static method Type.getDescriptor, which takes a
|
||||
Class as a parameter.</p>
|
||||
|
||||
<p>Examples:</p>
|
||||
<ul>
|
||||
|
||||
<li>
|
||||
<code>String desc = Type.getDescriptor(String.class);</code>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<code>String desc = Type.getDescriptor(int.class);</code>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<code>String desc = Type.getDescriptor(java.io.ObjectOutput.class);</code>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
<h3>
|
||||
<a name="Q9"></a>9. How do I generate Setters and Getters for my class?</h3>
|
||||
|
||||
|
||||
<p>Use the following code (this assumes that visitMaxs are computed by ASM - see
|
||||
<a href="#Q3">"3. How do I make ASM calculate visitMaxs for me?"</a>):</p>
|
||||
|
||||
<pre>void createSetter (String propertyName, String type, Class c) {
|
||||
String methodName = "set" + propertyName.substring(0, 1).toUpperCase() + propertyName.substring(1);
|
||||
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, methodName, "(" + type + ")V", null, null);
|
||||
mv.visitVarInsn(ALOAD, 0);
|
||||
mv.visitVarInsn(Type.getType(c).getOpcode(ILOAD), 1);
|
||||
mv.visitFieldInsn(PUTFIELD, className, propertyName, type);
|
||||
mv.visitInsn(RETURN);
|
||||
mv.visitMaxs(0, 0);
|
||||
}
|
||||
|
||||
void createGetter (String propertyName, String returnType, Class c) {
|
||||
String methodName = "get" + propertyName.substring(0, 1).toUpperCase() + propertyName.substring(1);
|
||||
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, methodName, "()" + returnType, null, null);
|
||||
mv.visitVarInsn(ALOAD, 0);
|
||||
mv.visitFieldInsn(GETFIELD, internalClassName, propertyName, returnType);
|
||||
mv.visitInsn(Type.getType(c).getOpcode(IRETURN));
|
||||
mv.visitMaxs(0, 0);
|
||||
}</pre>
|
||||
|
||||
|
||||
|
||||
<h3>
|
||||
<a name="Q10"></a>10. How do I get the bytecode of an existing class?</h3>
|
||||
|
||||
|
||||
<p>If you want the bytecode instructions themselves, use TraceClassVisitor. If you
|
||||
want the ASM code to generate these bytecode instructions, use ASMifierClassVisitor.
|
||||
Both classes provide a "main" method to allow them to be
|
||||
called from the command line, passing your fully qualified class name as a
|
||||
parameter.
|
||||
Example:</p>
|
||||
|
||||
<p>
|
||||
<code>java -classpath "asm.jar;asm-util.jar;yourjar.jar"
|
||||
org.objectweb.asm.util.ASMifierClassVisitor org.domain.package.YourClass</code>
|
||||
</p>
|
||||
|
||||
<p>or</p>
|
||||
|
||||
<p>
|
||||
<code>java -classpath "asm.jar;asm-util.jar"
|
||||
org.objectweb.asm.util.ASMifierClassVisitor org/domain/package/YourClass.class</code>
|
||||
</p>
|
||||
|
||||
<p>Another, much easier method, if you are using Eclipse, is to use the
|
||||
<a href="../eclipse/bco/index.html">Bytecode Outline</a> plugin.</p>
|
||||
|
||||
|
||||
<h3>
|
||||
<a name="Q11"></a>11. How do I generate [some Java code] with ASM?</h3>
|
||||
|
||||
|
||||
<p>If you want to know how to generate a synchronized block, a try catch
|
||||
block, a finally statement, or any other Java construct, write the Java code
|
||||
you want to generate in a temporary class, compile it with javac, and then
|
||||
use the ASMifierClassVisitor to get the ASM code that will generate this class (see
|
||||
<a href="#Q10">"10. How do I get the bytecode of an existing class?"</a>).
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<h3>
|
||||
<a name="Q12"></a>12. How does the [xxx] bytecode instruction work?</h3>
|
||||
|
||||
|
||||
<p>See <a href="http://java.sun.com/docs/books/vmspec/2nd-edition/html/Instructions.doc.html">chapter
|
||||
6</a> of the Java Virtual Machine Specification.
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<h3>
|
||||
<a name="Q13"></a>13. Is ASM thread safe?</h3>
|
||||
|
||||
|
||||
<p>The Type and ClassReader classes are thread safe, i.e. several threads can
|
||||
use a single Type object or a single ClassReader object concurrently without
|
||||
problems. The ClassWriter and MethodWriter classes are <em>not</em> thread safe,
|
||||
i.e. a single class cannot be generated by several concurrent threads (but,
|
||||
of course, several threads can generate distinct classes concurrently, if each
|
||||
thread uses its own ClassWriter instance). In order to generate a single class
|
||||
by using several concurrent threads, one should use ClassAdapter and
|
||||
MethodAdapter instances that delegate to normal ClassWriter and MethodWriter
|
||||
instances, and whose methods are all synchronized.</p>
|
||||
|
||||
<p>More generally, ClassVisitor and MethodVisitor implementations, such as
|
||||
ClassWriter and ClassAdapter, do not have to be thread safe. However, non thread
|
||||
safe visitors can be made thread safe just by using a synchronizing class
|
||||
adapter in front of them.</p>
|
||||
|
||||
|
||||
|
||||
<h3>
|
||||
<a name="Q14"></a>14. What is the earliest JDK required to use ASM?</h3>
|
||||
|
||||
|
||||
<p>The org.objectweb.asm package should work with JDK 1.1, or even with JDK 1.0
|
||||
if Type is not used. Indeed, this package only requires the following JDK classes
|
||||
and methods:</p>
|
||||
|
||||
<ul>
|
||||
|
||||
<li>in java.io: InputStream, IOException (only in two constructors of
|
||||
ClassReader)</li>
|
||||
|
||||
<li>in java.lang.reflect: Method (only in Type)</li>
|
||||
|
||||
<li>in java.lang:
|
||||
<ul>
|
||||
|
||||
<li>Object, String, StringBuffer</li>
|
||||
|
||||
<li>Long, Double, Float, Void, Byte, Boolean ...</li>
|
||||
|
||||
<li>System.arraycopy</li>
|
||||
|
||||
<li>ClassLoader.getSystemClassLoader,
|
||||
ClassLoader.getSystemResourceAsStream (only in one constructor of
|
||||
ClassReader)</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
<p>The asm.util and asm.tree packages require JDK 1.2, since they use the
|
||||
List interface and the ArrayList class.
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<h3>
|
||||
<a name="Q15"></a>15. How to resolve conflicts between different ASM API
|
||||
versions available in a global classpath or within the same ClassLoader?</h3>
|
||||
|
||||
|
||||
<p>Tools and frameworks that are using ASM for bytecode
|
||||
processing (e.g. Hibernate, CGLIB, AspectWerkz) should repackage
|
||||
ASM code within their own name space. This can be automated with
|
||||
<a href="http://tonicsystems.com/products/jarjar/">Jar Jar Links</a> tool.</p>
|
||||
|
||||
|
||||
</td><td valign="top" width="10"><img alt=" " height="1" width="10" src="../images/pix.gif"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" width="20"><img alt=" " height="1" width="20" src="../images/pix.gif"></td><td valign="top" width="160"><img alt=" " height="1" width="160" src="../images/pix.gif"></td><td valign="top"><img alt=" " height="1" width="465" src="../images/pix.gif"><br>
|
||||
<address>Copyright © 1999-2005, <a href="http://www.objectweb.org/">ObjectWeb Consortium</a> | <a href="http://consortium.objectweb.org/contact.html">contact</a> | <a href="mailto:webmaster@objectweb.org">webmaster</a> | Last modified at 2009-02-16 10:31 AM</address>
|
||||
</td><td valign="top" width="10"><img alt=" " height="1" width="10" src="../images/pix.gif"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<br>
|
||||
</body>
|
||||
</html>
|
14
objectweb-asm-2.2.3,pom
Normal file
14
objectweb-asm-2.2.3,pom
Normal file
@ -0,0 +1,14 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<artifactId>asm-parent</artifactId>
|
||||
<groupId>asm</groupId>
|
||||
<version>2.2.3</version>
|
||||
</parent>
|
||||
|
||||
<name>ASM Core</name>
|
||||
<artifactId>asm</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
</project>
|
15
objectweb-asm-all-2.2.3,pom
Normal file
15
objectweb-asm-all-2.2.3,pom
Normal file
@ -0,0 +1,15 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>asm</groupId>
|
||||
<artifactId>asm-parent</artifactId>
|
||||
<version>2.2.3</version>
|
||||
</parent>
|
||||
|
||||
<name>ASM All</name>
|
||||
<groupId>asm</groupId>
|
||||
<artifactId>asm-all</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
</project>
|
21
objectweb-asm-analysis-2.2.3,pom
Normal file
21
objectweb-asm-analysis-2.2.3,pom
Normal file
@ -0,0 +1,21 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<artifactId>asm-parent</artifactId>
|
||||
<groupId>asm</groupId>
|
||||
<version>2.2.3</version>
|
||||
</parent>
|
||||
|
||||
<name>ASM Analysis</name>
|
||||
<artifactId>asm-analysis</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<artifactId>asm-tree</artifactId>
|
||||
<groupId>asm</groupId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
21
objectweb-asm-attrs-2.2.3,pom
Normal file
21
objectweb-asm-attrs-2.2.3,pom
Normal file
@ -0,0 +1,21 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<artifactId>asm-parent</artifactId>
|
||||
<groupId>asm</groupId>
|
||||
<version>2.2.3</version>
|
||||
</parent>
|
||||
|
||||
<name>ASM Atributes</name>
|
||||
<artifactId>asm-attrs</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<artifactId>asm</artifactId>
|
||||
<groupId>asm</groupId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
21
objectweb-asm-commons-2.2.3,pom
Normal file
21
objectweb-asm-commons-2.2.3,pom
Normal file
@ -0,0 +1,21 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<artifactId>asm-parent</artifactId>
|
||||
<groupId>asm</groupId>
|
||||
<version>2.2.3</version>
|
||||
</parent>
|
||||
|
||||
<name>ASM Commons</name>
|
||||
<artifactId>asm-commons</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<artifactId>asm-tree</artifactId>
|
||||
<groupId>asm</groupId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
91
objectweb-asm-parent-2.2.3,pom
Normal file
91
objectweb-asm-parent-2.2.3,pom
Normal file
@ -0,0 +1,91 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>asm-parent</artifactId>
|
||||
<groupId>asm</groupId>
|
||||
<version>2.2.3</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>ASM</name>
|
||||
<description>A very small and fast Java bytecode manipulation framework</description>
|
||||
<url>http://asm.objectweb.org/</url>
|
||||
|
||||
<organization>
|
||||
<name>ObjectWeb</name>
|
||||
<url>http://www.objectweb.org/</url>
|
||||
</organization>
|
||||
<inceptionYear>2000</inceptionYear>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<name>Eric Bruneton</name>
|
||||
<id>ebruneton</id>
|
||||
<email>Eric.Bruneton@rd.francetelecom.com</email>
|
||||
<roles>
|
||||
<role>Creator</role>
|
||||
<role>Java Developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<name>Eugene Kuleshov</name>
|
||||
<id>eu</id>
|
||||
<email>eu@javatx.org</email>
|
||||
<roles>
|
||||
<role>Java Developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<scm>
|
||||
<connection>scm:cvs:pserver:anonymous@cvs.forge.objectweb.org:/cvsroot/asm:asm</connection>
|
||||
<developerConnection>scm:cvs:ext:${maven.username}@cvs.forge.objectweb.org:/cvsroot/asm:asm</developerConnection>
|
||||
<url>http://cvs.forge.objectweb.org/cgi-bin/viewcvs.cgi/asm/asm/</url>
|
||||
</scm>
|
||||
|
||||
<issueManagement>
|
||||
<url>http://forge.objectweb.org/tracker/?group_id=23</url>
|
||||
</issueManagement>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<artifactId>asm</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<artifactId>asm-tree</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<artifactId>asm-analysis</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<artifactId>asm-commons</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<artifactId>asm-util</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<artifactId>asm-xml</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
</project>
|
21
objectweb-asm-tree-2.2.3,pom
Normal file
21
objectweb-asm-tree-2.2.3,pom
Normal file
@ -0,0 +1,21 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<artifactId>asm-parent</artifactId>
|
||||
<groupId>asm</groupId>
|
||||
<version>2.2.3</version>
|
||||
</parent>
|
||||
|
||||
<name>ASM Tree</name>
|
||||
<artifactId>asm-tree</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<artifactId>asm</artifactId>
|
||||
<groupId>asm</groupId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
21
objectweb-asm-util-2.2.3,pom
Normal file
21
objectweb-asm-util-2.2.3,pom
Normal file
@ -0,0 +1,21 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<artifactId>asm-parent</artifactId>
|
||||
<groupId>asm</groupId>
|
||||
<version>2.2.3</version>
|
||||
</parent>
|
||||
|
||||
<name>ASM Util</name>
|
||||
<artifactId>asm-util</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<artifactId>asm-tree</artifactId>
|
||||
<groupId>asm</groupId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
21
objectweb-asm-xml-2.2.3,pom
Normal file
21
objectweb-asm-xml-2.2.3,pom
Normal file
@ -0,0 +1,21 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<artifactId>asm-parent</artifactId>
|
||||
<groupId>asm</groupId>
|
||||
<version>2.2.3</version>
|
||||
</parent>
|
||||
|
||||
<name>ASM XML</name>
|
||||
<artifactId>asm-xml</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<artifactId>asm-util</artifactId>
|
||||
<groupId>asm</groupId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
49
objectweb-asm2-2.2.3-ALLPerfTest.patch
Normal file
49
objectweb-asm2-2.2.3-ALLPerfTest.patch
Normal file
@ -0,0 +1,49 @@
|
||||
--- asm-2.2.3/test/perf/org/objectweb/asm/ALLPerfTest.java 2006-07-05 17:32:24.000000000 +0200
|
||||
+++ asm-2.2.3/test/perf/org/objectweb/asm/ALLPerfTest.java-gil 2009-03-01 19:21:30.000000000 +0100
|
||||
@@ -172,9 +172,9 @@
|
||||
System.out.println("\nBCEL PERFORMANCES\n");
|
||||
new BCELPerfTest().perfs(args);
|
||||
double[][] bcelPerfs = perfs;
|
||||
- System.out.println("\nSERP PERFORMANCES\n");
|
||||
- new SERPPerfTest().perfs(args);
|
||||
- double[][] serpPerfs = perfs;
|
||||
+// System.out.println("\nSERP PERFORMANCES\n");
|
||||
+// new SERPPerfTest().perfs(args);
|
||||
+// double[][] serpPerfs = perfs;
|
||||
System.out.println("\nJavassist PERFORMANCES\n");
|
||||
new JavassistPerfTest().perfs(args);
|
||||
double[][] javassistPerfs = perfs;
|
||||
@@ -212,12 +212,12 @@
|
||||
System.out.print(")");
|
||||
}
|
||||
System.out.print(" ");
|
||||
- System.out.print((float) serpPerfs[step][mode] + " ms");
|
||||
- if (mode > 0) {
|
||||
- System.out.print(" (*");
|
||||
- System.out.print((float) (serpPerfs[step][mode] / serpPerfs[step][0]));
|
||||
- System.out.print(")");
|
||||
- }
|
||||
+// System.out.print((float) serpPerfs[step][mode] + " ms");
|
||||
+// if (mode > 0) {
|
||||
+// System.out.print(" (*");
|
||||
+// System.out.print((float) (serpPerfs[step][mode] / serpPerfs[step][0]));
|
||||
+// System.out.print(")");
|
||||
+// }
|
||||
System.out.print(" ");
|
||||
System.out.print((float) javassistPerfs[step][mode] + " ms");
|
||||
if (mode > 0) {
|
||||
@@ -258,10 +258,10 @@
|
||||
System.out.print((float) f + " ms (*");
|
||||
System.out.print((float) (f / ref));
|
||||
System.out.print(") ");
|
||||
- double g = serpPerfs[step][mode] - serpPerfs[step][base];
|
||||
- System.out.print((float) g + " ms (*");
|
||||
- System.out.print((float) (g / ref));
|
||||
- System.out.print(")");
|
||||
+// double g = serpPerfs[step][mode] - serpPerfs[step][base];
|
||||
+// System.out.print((float) g + " ms (*");
|
||||
+// System.out.print((float) (g / ref));
|
||||
+// System.out.print(")");
|
||||
double h = javassistPerfs[step][mode]
|
||||
- javassistPerfs[step][base];
|
||||
System.out.print((float) h + " ms (*");
|
11
objectweb-asm2-2.2.3-SerialVersionUIDAdder.patch
Normal file
11
objectweb-asm2-2.2.3-SerialVersionUIDAdder.patch
Normal file
@ -0,0 +1,11 @@
|
||||
--- asm-2.2.3/src/org/objectweb/asm/commons/SerialVersionUIDAdder.java 2006-07-05 17:32:20.000000000 +0200
|
||||
+++ asm-2.2.3/src/org/objectweb/asm/commons/SerialVersionUIDAdder.java-gil 2009-03-01 19:08:16.000000000 +0100
|
||||
@@ -431,7 +431,7 @@
|
||||
try {
|
||||
return MessageDigest.getInstance("SHA").digest(value);
|
||||
} catch (Exception e) {
|
||||
- throw new UnsupportedOperationException(e);
|
||||
+ throw new UnsupportedOperationException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
17
objectweb-asm2-2.2.3-build_xml.patch
Normal file
17
objectweb-asm2-2.2.3-build_xml.patch
Normal file
@ -0,0 +1,17 @@
|
||||
--- asm-2.2.3/build.xml 2006-07-05 17:32:20.000000000 +0200
|
||||
+++ asm-2.2.3/build.xml-gil 2009-03-01 19:02:16.000000000 +0100
|
||||
@@ -98,10 +98,10 @@
|
||||
|
||||
<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="cobertura.jar"/>
|
||||
+ <include name="log4j.jar"/>
|
||||
+ <include name="jakarta-oro.jar"/>
|
||||
+ <include name="asm2.jar"/>
|
||||
<include name="ccl.jar"/>
|
||||
<include name="javancss.jar"/>
|
||||
</fileset>
|
11
objectweb-asm2-2.2.3-noclasspathinmanifest.patch
Normal file
11
objectweb-asm2-2.2.3-noclasspathinmanifest.patch
Normal file
@ -0,0 +1,11 @@
|
||||
--- asm-2.2.3/archive/asm-xml.xml 2006-07-05 17:32:30.000000000 +0200
|
||||
+++ asm-2.2.3/archive/asm-xml.xml-gil 2009-03-01 18:55:03.000000000 +0100
|
||||
@@ -10,7 +10,7 @@
|
||||
<attribute name="Implementation-Title" value="ASM XML classes"/>
|
||||
<attribute name="Implementation-Version" value="${product.artifact}"/>
|
||||
<attribute name="Implementation-Vendor" value="Eugene Kuleshov"/>
|
||||
- <attribute name="Class-path" value="asm-${product.artifact}.jar asm-util-${product.artifact}.jar asm-attrs-${product.artifact}.jar"/>
|
||||
+ <!--attribute name="Class-path" value="asm-${product.artifact}.jar asm-util-${product.artifact}.jar asm-attrs-${product.artifact}.jar"/>-->
|
||||
<attribute name="Main-class" value="org.objectweb.asm.xml.Processor"/>
|
||||
</manifest>
|
||||
</jar>
|
12
objectweb-asm2-2.2.3-test-build_xml.patch
Normal file
12
objectweb-asm2-2.2.3-test-build_xml.patch
Normal file
@ -0,0 +1,12 @@
|
||||
--- asm-2.2.3/build.xml 2009-03-01 19:12:00.000000000 +0100
|
||||
+++ asm-2.2.3/build.xml-gil 2009-03-01 19:13:54.000000000 +0100
|
||||
@@ -87,7 +87,9 @@
|
||||
|
||||
<target name="check" unless="paths.configured">
|
||||
<echo message="The 'build.properties' file must be configured"/>
|
||||
+<!--
|
||||
<fail/>
|
||||
+-->
|
||||
</target>
|
||||
|
||||
<target name="init" depends="properties,check">
|
36
objectweb-asm2-2.2.3-test-heap.patch
Normal file
36
objectweb-asm2-2.2.3-test-heap.patch
Normal file
@ -0,0 +1,36 @@
|
||||
diff -Nru asm-2.2.3/test/conform/asmifier.xml asm-2.2.3/test/conform-gil/asmifier.xml
|
||||
--- asm-2.2.3/test/conform/asmifier.xml 2006-07-05 17:32:22.000000000 +0200
|
||||
+++ asm-2.2.3/test/conform-gil/asmifier.xml 2009-03-01 19:28:50.000000000 +0100
|
||||
@@ -12,6 +12,8 @@
|
||||
</batchtest>
|
||||
<formatter type="xml"/>
|
||||
<classpath refid="test.classpath"/>
|
||||
+ <jvmarg value="-Xmx1280m"/>
|
||||
+ <jvmarg value="-XX:MaxPermSize=128m"/>
|
||||
<jvmarg value="-Dasm.test=${asm.test}"/>
|
||||
<jvmarg value="-Dasm.test.class=${asm.test.class}"/>
|
||||
</junit>
|
||||
diff -Nru asm-2.2.3/test/conform/dataflow.xml asm-2.2.3/test/conform-gil/dataflow.xml
|
||||
--- asm-2.2.3/test/conform/dataflow.xml 2006-07-05 17:32:15.000000000 +0200
|
||||
+++ asm-2.2.3/test/conform-gil/dataflow.xml 2009-03-01 19:27:47.000000000 +0100
|
||||
@@ -12,6 +12,8 @@
|
||||
</batchtest>
|
||||
<formatter type="xml"/>
|
||||
<classpath refid="test.classpath"/>
|
||||
+ <jvmarg value="-Xmx1280m"/>
|
||||
+ <jvmarg value="-XX:MaxPermSize=128m"/>
|
||||
<jvmarg value="-Dasm.test=${asm.test}"/>
|
||||
<jvmarg value="-Dasm.test.class=${asm.test.class}"/>
|
||||
</junit>
|
||||
diff -Nru asm-2.2.3/test/conform/gasmifier.xml asm-2.2.3/test/conform-gil/gasmifier.xml
|
||||
--- asm-2.2.3/test/conform/gasmifier.xml 2006-07-05 17:32:24.000000000 +0200
|
||||
+++ asm-2.2.3/test/conform-gil/gasmifier.xml 2009-03-01 19:29:39.000000000 +0100
|
||||
@@ -12,6 +12,8 @@
|
||||
</batchtest>
|
||||
<formatter type="xml"/>
|
||||
<classpath refid="test.classpath"/>
|
||||
+ <jvmarg value="-Xmx1280m"/>
|
||||
+ <jvmarg value="-XX:MaxPermSize=128m"/>
|
||||
<jvmarg value="-Dasm.test=${asm.test}"/>
|
||||
<jvmarg value="-Dasm.test.class=${asm.test.class}"/>
|
||||
</junit>
|
276
objectweb-asm2.spec
Normal file
276
objectweb-asm2.spec
Normal file
@ -0,0 +1,276 @@
|
||||
%define javahome %{_jvmdir}/jdk
|
||||
Name: objectweb-asm2
|
||||
Version: 2.2.3
|
||||
Release: 3mamba
|
||||
Summary: a code manipulation tool to implement adaptable systems
|
||||
Group: Development/Libraries/Java
|
||||
Vendor: openmamba
|
||||
Distribution: openmamba
|
||||
Packager: Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
URL: http://asm.objectweb.org/
|
||||
Source0: http://download.forge.objectweb.org/asm/asm-%{version}.tar.gz
|
||||
Source1: http://asm.objectweb.org/current/asm-eng.pdf
|
||||
Source2: http://asm.objectweb.org/current/asm-transformations.pdf
|
||||
Source3: http://download.forge.objectweb.org/asm/asm-guide.pdf
|
||||
Source4: http://asm.objectweb.org/doc/faq.html
|
||||
# http://mirrors.ibiblio.org/pub/mirrors/maven2/asm
|
||||
Source5: objectweb-asm-parent-2.2.3,pom
|
||||
Source6: objectweb-asm-2.2.3,pom
|
||||
Source7: objectweb-asm-all-2.2.3,pom
|
||||
Source8: objectweb-asm-analysis-2.2.3,pom
|
||||
Source9: objectweb-asm-attrs-2.2.3,pom
|
||||
Source10: objectweb-asm-commons-2.2.3,pom
|
||||
Source11: objectweb-asm-tree-2.2.3,pom
|
||||
Source12: objectweb-asm-util-2.2.3,pom
|
||||
Source13: objectweb-asm-xml-2.2.3,pom
|
||||
Patch0: objectweb-asm2-2.2.3-noclasspathinmanifest.patch
|
||||
Patch1: objectweb-asm2-2.2.3-build_xml.patch
|
||||
Patch2: objectweb-asm2-2.2.3-SerialVersionUIDAdder.patch
|
||||
Patch3: objectweb-asm2-2.2.3-test-build_xml.patch
|
||||
Patch4: objectweb-asm2-2.2.3-ALLPerfTest.patch
|
||||
Patch5: objectweb-asm2-2.2.3-test-heap.patch
|
||||
License: BSD
|
||||
BuildRequires: apache-ant
|
||||
BuildRequires: apache-log4j
|
||||
BuildRequires: jakarta-bcel
|
||||
%if "%{stage1}" != "1"
|
||||
BuildRequires: jakarta-oro
|
||||
BuildRequires: java-serp
|
||||
BuildRequires: janino
|
||||
BuildRequires: javassist
|
||||
%endif
|
||||
BuildRequires: objectweb-anttask
|
||||
BuildRequires: jpackage-utils
|
||||
BuildRequires: zip
|
||||
BuildRequires: xml-commons-apis
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-root
|
||||
|
||||
%description
|
||||
ASM is an all purpose Java bytecode manipulation and analysis framework. It can be used to modify existing classes or dynamically generate classes, directly in binary form. Provided common transformations and analysis algorithms allow to easily assemble custom complex transformations and code analysis tools.
|
||||
ASM offer similar functionality as other bytecode frameworks, but it is focused on simplicity of use and performance. Because it was designed and implemented to be as small and as fast as possible, it makes it very attractive for using in dynamic systems*.
|
||||
(*) ASM can of course be used in a static way too.
|
||||
|
||||
%package javadoc
|
||||
Group: Documentation
|
||||
Summary: Javadoc for %{name}
|
||||
|
||||
%description javadoc
|
||||
ASM is an all purpose Java bytecode manipulation and analysis framework
|
||||
|
||||
This package contains javadoc for %{name}.
|
||||
|
||||
%package manual
|
||||
Group: Documentation
|
||||
Summary: Documents for %{name}
|
||||
|
||||
%description manual
|
||||
ASM is an all purpose Java bytecode manipulation and analysis framework
|
||||
|
||||
This package contains documentation for %{name}.
|
||||
|
||||
%package demo
|
||||
Group: Documentation
|
||||
Summary: Examples for %{name}
|
||||
Requires: %{name} = %{version}
|
||||
|
||||
%description demo
|
||||
ASM is an all purpose Java bytecode manipulation and analysis framework
|
||||
|
||||
This package contains documentation and samples for %{name}.
|
||||
|
||||
%prep
|
||||
|
||||
%setup -q -n asm-%{version}
|
||||
%patch0 -p1
|
||||
|
||||
for j in $(find . -name "*.jar"); do
|
||||
mv $j ${j}.no
|
||||
done
|
||||
|
||||
mkdir test/lib
|
||||
|
||||
#tests
|
||||
#pushd test/lib
|
||||
# ln -sf $(build-classpath asm2/asm2)
|
||||
# ln -sf $(build-classpath cobertura)
|
||||
# ln -sf $(build-classpath log4j)
|
||||
# ln -sf $(build-classpath jakarta-oro)
|
||||
# ln -sf $(build-classpath ccl-util) ccl.jar
|
||||
# ln -sf $(build-classpath javancss)
|
||||
#popd
|
||||
%patch1 -p1
|
||||
%patch2 -p1
|
||||
%patch3 -p1
|
||||
%patch4 -p1
|
||||
%patch5 -p1
|
||||
|
||||
rm test/perf/org/objectweb/asm/SERPPerfTest.java
|
||||
rm test/conform/adviceadapter2.xml
|
||||
|
||||
%build
|
||||
# tests
|
||||
# export CLASSPATH=$(build-classpath asm2/asm2 asm2/asm2-tree)
|
||||
ant \
|
||||
-Dbcel.path=$(build-classpath bcel-5.2) \
|
||||
-Dobjectweb.ant.tasks.path=$(build-classpath objectweb-anttask-1.3.2) \
|
||||
%if "%{stage1}" != "1"
|
||||
-Djanino.path=$(build-classpath janino-2.5.15) \
|
||||
-Djavassist.path=$(build-classpath javassist-3.9.0) \
|
||||
-Dserp.jar=$(build-classpath serp) \
|
||||
%endif
|
||||
jar \
|
||||
jdoc \
|
||||
examples
|
||||
|
||||
# tests
|
||||
# coverage \
|
||||
# test \
|
||||
# coverage.report \
|
||||
# test.report \
|
||||
|
||||
|
||||
# compile
|
||||
# compile-debug
|
||||
# coverage
|
||||
# coverage.report
|
||||
# dist
|
||||
# dist.init
|
||||
# dist.version
|
||||
# example
|
||||
# examples
|
||||
# jar
|
||||
# jdoc
|
||||
# noshrink
|
||||
# properties
|
||||
# shrink
|
||||
# test
|
||||
# test.report
|
||||
|
||||
|
||||
sed -i 's/\r//g' README.txt LICENSE.txt
|
||||
|
||||
%install
|
||||
[ "%{buildroot}" != / ] && rm -rf "%{buildroot}"
|
||||
|
||||
mkdir -p %{buildroot}%{_javadir}/asm2
|
||||
for jar in output/dist/lib/*.jar; do
|
||||
newjar=${jar/asm-/asm2-}
|
||||
install -m 644 ${jar} \
|
||||
%{buildroot}%{_javadir}/asm2/`basename ${newjar}`
|
||||
done
|
||||
|
||||
install -m 644 output/dist/lib/all/asm-all-%{version}.jar \
|
||||
%{buildroot}%{_javadir}/asm2-all-%{version}.jar
|
||||
|
||||
(
|
||||
cd %{buildroot}%{_javadir}
|
||||
for jar in *-%{version}*; do
|
||||
ln -sf ${jar} ${jar/-%{version}/}
|
||||
done
|
||||
)
|
||||
|
||||
(
|
||||
cd %{buildroot}%{_javadir}/asm2
|
||||
for jar in *-%{version}* ; do
|
||||
ln -sf ${jar} ${jar/-%{version}/}
|
||||
done
|
||||
)
|
||||
|
||||
|
||||
mkdir -p %{buildroot}%{_datadir}/maven2/poms
|
||||
|
||||
install -m 644 %{SOURCE5} %{buildroot}%{_datadir}/maven2/poms/JPP.objectweb-asm2-asm-parent.pom
|
||||
%add_to_maven_depmap asm asm-parent %{version} JPP/asm2 asm-parent
|
||||
install -m 644 %{SOURCE6} %{buildroot}%{_datadir}/maven2/poms/JPP.objectweb-asm2-asm2.pom
|
||||
%add_to_maven_depmap asm asm %{version} JPP/asm2 asm2
|
||||
install -m 644 %{SOURCE7} %{buildroot}%{_datadir}/maven2/poms/JPP.objectweb-asm2-asm2-all.pom
|
||||
%add_to_maven_depmap asm asm-all %{version} JPP/asm2 asm2-all
|
||||
install -m 644 %{SOURCE8} %{buildroot}%{_datadir}/maven2/poms/JPP.objectweb-asm2-asm2-analysis.pom
|
||||
%add_to_maven_depmap asm asm-analysis %{version} JPP/asm2 asm2-analysis
|
||||
install -m 644 %{SOURCE9} %{buildroot}%{_datadir}/maven2/poms/JPP.objectweb-asm2-asm2-attrs.pom
|
||||
%add_to_maven_depmap asm asm-attrs %{version} JPP/asm2 asm2-attrs
|
||||
install -m 644 %{SOURCE10} %{buildroot}%{_datadir}/maven2/poms/JPP.objectweb-asm2-asm2-commons.pom
|
||||
%add_to_maven_depmap asm asm-commons %{version} JPP/asm2 asm2-commons
|
||||
install -m 644 %{SOURCE11} %{buildroot}%{_datadir}/maven2/poms/JPP.objectweb-asm2-asm2-tree.pom
|
||||
%add_to_maven_depmap asm asm-tree %{version} JPP/asm2 asm2-tree
|
||||
install -m 644 %{SOURCE12} %{buildroot}%{_datadir}/maven2/poms/JPP.objectweb-asm2-asm2-util.pom
|
||||
%add_to_maven_depmap asm asm-util %{version} JPP/asm2 asm2-util
|
||||
install -m 644 %{SOURCE13} %{buildroot}%{_datadir}/maven2/poms/JPP.objectweb-asm2-asm2-xml.pom
|
||||
%add_to_maven_depmap asm asm-xml %{version} JPP/asm2 asm2-xml
|
||||
|
||||
|
||||
mkdir -p %{buildroot}%{_javadocdir}/asm2-%{version}
|
||||
cp -pr output/dist/doc/javadoc/user/* %{buildroot}%{_javadocdir}/asm2-%{version}
|
||||
|
||||
(
|
||||
cd %{buildroot}%{_javadocdir}
|
||||
ln -sf asm2-%{version} asm2
|
||||
)
|
||||
|
||||
mkdir -p %{buildroot}%{_docdir}/asm2-%{version}
|
||||
install -m 644 README.txt %{buildroot}%{_docdir}/asm2-%{version}
|
||||
install -m 644 LICENSE.txt %{buildroot}%{_docdir}/asm2-%{version}
|
||||
install -m 644 %{S:1} %{buildroot}%{_docdir}/asm2-%{version}
|
||||
install -m 644 %{S:2} %{buildroot}%{_docdir}/asm2-%{version}
|
||||
install -m 644 %{S:3} %{buildroot}%{_docdir}/asm2-%{version}
|
||||
install -m 644 %{S:4} %{buildroot}%{_docdir}/asm2-%{version}
|
||||
|
||||
mkdir -p %{buildroot}%{_datadir}/asm2-%{version}
|
||||
cp -pr output/dist/examples %{buildroot}%{_datadir}/asm2-%{version}
|
||||
|
||||
|
||||
%clean
|
||||
[ "%{buildroot}" != / ] && rm -rf "%{buildroot}"
|
||||
|
||||
%post
|
||||
%update_maven_depmap
|
||||
|
||||
%postun
|
||||
%update_maven_depmap
|
||||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
%{_javadir}/asm2-all-%{version}.jar
|
||||
%{_javadir}/asm2-all.jar
|
||||
%dir %{_javadir}/asm2
|
||||
%{_javadir}/asm2/asm2-%{version}.jar
|
||||
%{_javadir}/asm2/asm2.jar
|
||||
%{_javadir}/asm2/asm2-analysis-%{version}.jar
|
||||
%{_javadir}/asm2/asm2-analysis.jar
|
||||
%{_javadir}/asm2/asm2-attrs-%{version}.jar
|
||||
%{_javadir}/asm2/asm2-attrs.jar
|
||||
%{_javadir}/asm2/asm2-commons-%{version}.jar
|
||||
%{_javadir}/asm2/asm2-commons.jar
|
||||
%{_javadir}/asm2/asm2-tree-%{version}.jar
|
||||
%{_javadir}/asm2/asm2-tree.jar
|
||||
%{_javadir}/asm2/asm2-util-%{version}.jar
|
||||
%{_javadir}/asm2/asm2-util.jar
|
||||
%{_javadir}/asm2/asm2-xml-%{version}.jar
|
||||
%{_javadir}/asm2/asm2-xml.jar
|
||||
%{_datadir}/maven2/poms
|
||||
%{_mavendepmapfragdir}
|
||||
%doc LICENSE.txt README.txt
|
||||
|
||||
%files demo
|
||||
%defattr(-,root,root)
|
||||
%{_datadir}/asm2-%{version}
|
||||
|
||||
%files javadoc
|
||||
%defattr(-,root,root)
|
||||
%{_javadocdir}/asm2-%{version}
|
||||
%{_javadocdir}/asm2
|
||||
|
||||
%files manual
|
||||
%defattr(-,root,root)
|
||||
%{_docdir}/asm2-%{version}
|
||||
|
||||
%changelog
|
||||
* Sat Mar 26 2011 gil <puntogil@libero.it> 2.2.3-3mamba
|
||||
- rebuilt with java-gcj-compat support
|
||||
|
||||
* Sat Jan 09 2010 gil <puntogil@libero.it> 2.2.3-2mamba
|
||||
- rebuilt with java-serp support
|
||||
- added maven poms
|
||||
|
||||
* Sun Mar 01 2009 gil <puntogil@libero.it> 2.2.3-1mamba
|
||||
- package created by autospec
|
Loading…
Reference in New Issue
Block a user