[Jpackage-commits] dist/asm/JPP-6 Makefile, NONE, 1.1 asm-1.5.3.pom, NONE, 1.1 asm-analysis-1.5.3.pom, NONE, 1.1 asm-attrs-1.5.3.pom, NONE, 1.1 asm-component-info.xml, NONE, 1.1 asm-tree-1.5.3.pom, NONE, 1.1 asm-util-1.5.3.pom, NONE, 1.1 asm-xml-1.5.3.pom, NONE, 1.1 asm.spec, NONE, 1.1 faq.html, NONE, 1.1 kasm-1.5.3.pom, NONE, 1.1 sources, NONE, 1.1

jpackage jpackage at ryu.zarb.org
Sun Dec 5 21:17:42 CET 2010


Update of /home/projects/jpackage/cvs/dist/asm/JPP-6
In directory ryu.zarb.org:/tmp/cvs-serv19013/JPP-6

Added Files:
	Makefile asm-1.5.3.pom asm-analysis-1.5.3.pom 
	asm-attrs-1.5.3.pom asm-component-info.xml asm-tree-1.5.3.pom 
	asm-util-1.5.3.pom asm-xml-1.5.3.pom asm.spec faq.html 
	kasm-1.5.3.pom sources 
Log Message:
Import asm into JPP-6

--- NEW FILE: asm-analysis-1.5.3.pom ---
<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>asm</groupId>
  <artifactId>asm-analysis</artifactId>
  <name>asm-analysis</name>
  <version>1.5.3</version>
  <url>http://asm.objectweb.org/</url>
  <inceptionYear>2000</inceptionYear>
  <developers>
    <developer>
      <id>ebruneton</id>
      <name>Eric Bruneton</name>
      <email>Eric.Bruneton at rd.francetelecom.com</email>
      <roles>
        <role>Creator</role>
        <role>Java Developer</role>
      </roles>
    </developer>
    <developer>
      <id>eu</id>
      <name>Eugene Kuleshov</name>
      <email>eu at javatx.org</email>
      <roles>
        <role>Java Developer</role>
      </roles>
    </developer>
  </developers>
  <organization>
    <name>ObjectWeb</name>
    <url>http://www.objectweb.org/</url>
  </organization>
  <build />
</project>
--- NEW FILE: kasm-1.5.3.pom ---
<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>asm</groupId>
  <artifactId>kasm</artifactId>
  <name>kasm</name>
  <version>1.5.3</version>
  <url>http://asm.objectweb.org/</url>
  <inceptionYear>2000</inceptionYear>
  <developers>
    <developer>
      <id>ebruneton</id>
      <name>Eric Bruneton</name>
      <email>Eric.Bruneton at rd.francetelecom.com</email>
      <roles>
        <role>Creator</role>
        <role>Java Developer</role>
      </roles>
    </developer>
    <developer>
      <id>eu</id>
      <name>Eugene Kuleshov</name>
      <email>eu at javatx.org</email>
      <roles>
        <role>Java Developer</role>
      </roles>
    </developer>
  </developers>
  <organization>
    <name>ObjectWeb</name>
    <url>http://www.objectweb.org/</url>
  </organization>
  <build />
</project>
--- NEW FILE: Makefile ---
# Makefile for source rpm: asm
# $Id: Makefile,v 1.1 2010/12/05 20:17:40 jpackage Exp $
NAME := asm
SPECFILE = $(firstword $(wildcard *.spec))

define find-makefile-common
for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done
endef

MAKEFILE_COMMON := $(shell $(find-makefile-common))

ifeq ($(MAKEFILE_COMMON),)
# attept a checkout
define checkout-makefile-common
test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2
endef

MAKEFILE_COMMON := $(shell $(checkout-makefile-common))
endif

include $(MAKEFILE_COMMON)

--- NEW FILE: asm-1.5.3.pom ---
<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>asm</groupId>
  <artifactId>asm</artifactId>
  <name>asm</name>
  <version>1.5.3</version>
  <url>http://asm.objectweb.org/</url>
  <inceptionYear>2000</inceptionYear>
  <developers>
    <developer>
      <id>ebruneton</id>
      <name>Eric Bruneton</name>
      <email>Eric.Bruneton at rd.francetelecom.com</email>
      <roles>
        <role>Creator</role>
        <role>Java Developer</role>
      </roles>
    </developer>
    <developer>
      <id>eu</id>
      <name>Eugene Kuleshov</name>
      <email>eu at javatx.org</email>
      <roles>
        <role>Java Developer</role>
      </roles>
    </developer>
  </developers>
  <organization>
    <name>ObjectWeb</name>
    <url>http://www.objectweb.org/</url>
  </organization>
  <build />
</project>
--- NEW FILE: asm.spec ---
# Copyright (c) 2000-2010, JPackage Project
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the
#    distribution.
# 3. Neither the name of the JPackage Project nor the names of its
#    contributors may be used to endorse or promote products derived
#    from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

%define _without_gcj_support 1

%define gcj_support %{?_with_gcj_support:1}%{!?_with_gcj_support:%{?_without_gcj_support:0}%{!?_without_gcj_support:%{?_gcj_support:%{_gcj_support}}%{!?_gcj_support:0}}}

%define section free

%define _with_repolib 1

# If you want repolib package to be built,
# issue the following: 'rpmbuild --with repolib'
%define with_repolib %{?_with_repolib:1}%{!?_with_repolib:0}
%define without_repolib %{!?_with_repolib:1}%{?_with_repolib:0}

%define repodir %{_javadir}/repository.jboss.com/asm/1.5.3-brew
%define repodirlib %{repodir}/lib
%define repodirres %{repodir}/resources
%define repodirsrc %{repodir}/src
%define section free

Name:           asm
Version:        1.5.3
Release:        8%{?dist}
Epoch:          0
Summary:        Code manipulation tool to implement adaptable systems
License:        BSD
URL:            http://asm.objectweb.org/
Group:          Development/Libraries/Java
Source0:        http://download.us.forge.objectweb.org/asm/asm-1.5.3.tar.gz
Source1:        http://asm.objectweb.org/current/asm-eng.pdf
Source2:        http://asm.objectweb.org/doc/faq.html
Source3:        http://repo1.maven.org/maven2/asm/asm/1.5.3/asm-1.5.3.pom
Source4:        http://repo1.maven.org/maven2/asm/asm-analysis/1.5.3/asm-analysis-1.5.3.pom
Source5:        http://repo1.maven.org/maven2/asm/asm-attrs/1.5.3/asm-attrs-1.5.3.pom
Source6:        http://repo1.maven.org/maven2/asm/asm-tree/1.5.3/asm-tree-1.5.3.pom
Source7:        http://repo1.maven.org/maven2/asm/asm-util/1.5.3/asm-util-1.5.3.pom
Source8:        http://repo1.maven.org/maven2/asm/asm-xml/1.5.3/asm-xml-1.5.3.pom
Source9:        http://repo1.maven.org/maven2/asm/kasm/1.5.3/kasm-1.5.3.pom
Source10:       asm-component-info.xml
Requires:       java >= 0:1.6.0
Requires(post): jpackage-utils >= 0:1.7.5
Requires(postun): jpackage-utils >= 0:1.7.5
BuildRequires:  jpackage-utils >= 0:1.7.5
BuildRequires:  java-devel >= 0:1.6.0
BuildRequires:  ant >= 0:1.7.1
BuildRequires:  objectweb-anttask
%if %{gcj_support}
BuildRequires:  java-gcj-compat-devel
%else
BuildArch:      noarch
%endif
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root

%description
ASM is a code manipulation tool to implement adaptable systems.

%if %{with_repolib}
%package repolib
Summary:         Artifacts to be uploaded to a repository library
Group:           Development/Libraries/Java

%description repolib
Artifacts to be uploaded to a repository library.
This package is not meant to be installed but so its contents
can be extracted through rpm2cpio.
%endif

%package javadoc
Summary:        Javadoc for %{name}
Group:          Development/Documentation

%description javadoc
Javadoc for %{name}.

%prep
%setup -q
install -p -m 644 %{SOURCE1} .
install -p -m 644 %{SOURCE2} .

#Fix end of line encoding
sed -i 's/\r//g' README.txt
#Fix class path in manifest
sed -i '/Class\-path/d' archive/asm-xml.xml

%build
export CLASSPATH=
export OPT_JAR_LIST=:
ant -Dobjectweb.ant.tasks.path=$(build-classpath objectweb-anttask) jar jdoc

%install
rm -rf $RPM_BUILD_ROOT

# jars
install -d -m 755 $RPM_BUILD_ROOT%{_javadir}/%{name}
install -d -m 755 $RPM_BUILD_ROOT%{_datadir}/maven2/poms

install -p -m 644 output/dist/lib/asm-%{version}.jar $RPM_BUILD_ROOT%{_javadir}/%{name}/
install -p -m 644 %{SOURCE3} $RPM_BUILD_ROOT%{_datadir}/maven2/poms/JPP.asm-asm.pom
%add_to_maven_depmap asm asm %{version} JPP/%{name} asm

install -p -m 644 output/dist/lib/asm-analysis-%{version}.jar $RPM_BUILD_ROOT%{_javadir}/%{name}/
install -p -m 644 %{SOURCE4} $RPM_BUILD_ROOT%{_datadir}/maven2/poms/JPP.asm-asm-analysis.pom
%add_to_maven_depmap asm asm-analysis %{version} JPP/%{name} asm-analysis

install -p -m 644 output/dist/lib/asm-attrs-%{version}.jar $RPM_BUILD_ROOT%{_javadir}/%{name}/
install -p -m 644 %{SOURCE5} $RPM_BUILD_ROOT%{_datadir}/maven2/poms/JPP.asm-asm-attrs.pom
%add_to_maven_depmap asm asm-attrs %{version} JPP/%{name} asm-attrs

install -p -m 644 output/dist/lib/asm-tree-%{version}.jar $RPM_BUILD_ROOT%{_javadir}/%{name}/
install -p -m 644 %{SOURCE6} $RPM_BUILD_ROOT%{_datadir}/maven2/poms/JPP.asm-asm-tree.pom
%add_to_maven_depmap asm asm-tree %{version} JPP/%{name} asm-tree

install -p -m 644 output/dist/lib/asm-util-%{version}.jar $RPM_BUILD_ROOT%{_javadir}/%{name}/
install -p -m 644 %{SOURCE7} $RPM_BUILD_ROOT%{_datadir}/maven2/poms/JPP.asm-asm-util.pom
%add_to_maven_depmap asm asm-util %{version} JPP/%{name} asm-util

install -p -m 644 output/dist/lib/asm-xml-%{version}.jar $RPM_BUILD_ROOT%{_javadir}/%{name}/
install -p -m 644 %{SOURCE8} $RPM_BUILD_ROOT%{_datadir}/maven2/poms/JPP.asm-asm-xml.pom
%add_to_maven_depmap asm asm-xml %{version} JPP/%{name} asm-xml

install -p -m 644 output/dist/lib/kasm-%{version}.jar $RPM_BUILD_ROOT%{_javadir}/%{name}/
install -p -m 644 %{SOURCE9} $RPM_BUILD_ROOT%{_datadir}/maven2/poms/JPP.asm-kasm.pom
%add_to_maven_depmap asm kasm %{version} JPP/%{name} kasm

(cd $RPM_BUILD_ROOT%{_javadir}/%{name} && for jar in *-%{version}*; do ln -s ${jar} ${jar/-%{version}/}; done)

# javadoc
install -p -d -m 755 $RPM_BUILD_ROOT%{_javadocdir}/%{name}-%{version}
cp -pr output/dist/doc/javadoc/user/* $RPM_BUILD_ROOT%{_javadocdir}/%{name}-%{version}
ln -s %{name}-%{version} $RPM_BUILD_ROOT%{_javadocdir}/%{name}

%if %{gcj_support}
%{_bindir}/aot-compile-rpm
%endif

%if %{with_repolib}
install -d -m 755 $RPM_BUILD_ROOT%{repodir}
install -d -m 755 $RPM_BUILD_ROOT%{repodirlib}
install -p -m 644 %{SOURCE10} $RPM_BUILD_ROOT%{repodir}/component-info.xml
sed -i 's/@VERSION@/%{version}-brew/g' $RPM_BUILD_ROOT%{repodir}/component-info.xml
tag=`echo %{name}-%{version}-%{release} | sed 's|\.|_|g'`
sed -i "s/@TAG@/$tag/g" $RPM_BUILD_ROOT%{repodir}/component-info.xml
install -d -m 755 $RPM_BUILD_ROOT%{repodirsrc}
install -p -m 644 %{SOURCE0} $RPM_BUILD_ROOT%{repodirsrc}
cp -p $RPM_BUILD_ROOT%{_javadir}/asm/asm.jar $RPM_BUILD_ROOT%{repodirlib}
cp -p $RPM_BUILD_ROOT%{_javadir}/asm/asm-attrs.jar $RPM_BUILD_ROOT%{repodirlib}
%endif

%clean
rm -rf $RPM_BUILD_ROOT

%post
%update_maven_depmap
%if %{gcj_support}
if [ -x %{_bindir}/rebuild-gcj-db ]
then
  %{_bindir}/rebuild-gcj-db
fi
%endif

%postun
%update_maven_depmap
%if %{gcj_support}
if [ -x %{_bindir}/rebuild-gcj-db ]
then
  %{_bindir}/rebuild-gcj-db
fi
%endif

%files
%defattr(0644,root,root,0755)
%doc README.txt faq.html asm-eng.pdf
%dir %{_javadir}/%{name}
%{_javadir}/%{name}/*.jar
%{_datadir}/maven2/poms/*
%{_mavendepmapfragdir}/*
%if %{gcj_support}
%dir %{_libdir}/gcj/%{name}
%attr(-,root,root) %{_libdir}/gcj/%{name}/%{subname}-%{version}.jar.*
%endif

%files javadoc
%defattr(0644,root,root,0755)
%doc %{_javadocdir}/%{name}-%{version}
%doc %{_javadocdir}/%{name}

%if %{with_repolib}
%files repolib
%defattr(0644,root,root,0755)
%{_javadir}/repository.jboss.com
%endif

%changelog
* Sun Dec 05 2010 Ralph Apel <r.apel at r-apel.de> 0:1.5.3-8
- Adapt to JPP-6

* Tue Dec 09 2008 David Walluck <dwalluck at redhat.com> 0:1.5.3-7
- fix asm pom install
- fix component-info.xml install
- use explicit file list
- use asm instead of %%{name} where appropriate

* Thu Oct 09 2008 David Walluck <dwalluck at redhat.com> 0:1.5.3-6
- build for JPackage 5

* Mon Jun 10 2008 Permaine Cheung <pcheung at redhat.com> - 0:1.5.3-5
- Fix component-info.xml

* Tue Jun 03 2008 Permaine Cheung <pcheung at redhat.com> 0:1.5.3-4
- First JPP5 build

* Tue Mar 18 2008 Deepak Bhole <dbhole at redhat.com> 1.5.3-1jpp.ep1.2
- Added -repolib

* Mon Feb 11 2008 Ralph Apel <r.apel at r-apel.de> 0:1.5.3-3jpp
- Add poms and depmap frags
- Add gcj_support option

* Mon Mar 12 2007 Fernando Nasser <fnasser at redhat.com> 0:1.5.3-1jpp.ep1.1
- Rebuild

* Thu May 05 2005 Fernando Nasser <fnasser at redhat.com> 0:1.5.3-1jpp_1rh
- Merge with upstream for upgrade

* Fri Mar 11 2005 Sebastiano Vigna <vigna at acm.org> 0:1.5.3-1jpp
- Upgrade to 1.5.3

* Tue Feb 01 2005 Ralph Apel <r.apel at r-apel.de> 0:1.4.3-1jpp
- Upgrade to 1.4.3
- Require objectweb-anttask instead of owanttask

* Mon Nov 15 2004 Fernando Nasser <fnasser at redhat.com> 0:1.4.1-4jpp_1rh
- First Red Hat build

* Mon Sep 20 2004 Ralph Apel <r.apel at r-apel.de> 0:1.4.1-4jpp
- Require owanttask instead of monolog

* Fri Aug 20 2004 Ralph Apel <r.apel at r-apel.de> 0:1.4.1-3jpp
- Build with ant-1.6.2

* Sun Feb 08 2004 David Walluck <david at anti-microsoft.org> 0:1.4.1-2jpp
- this release uses new upstream tarball from author
- add some documentation from website

* Thu Jan 22 2004 David Walluck <david at anti-microsoft.org> 0:1.4.1-1jpp
- release

--- NEW FILE: asm-tree-1.5.3.pom ---
<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>asm</groupId>
  <artifactId>asm-tree</artifactId>
  <name>asm-tree</name>
  <version>1.5.3</version>
  <url>http://asm.objectweb.org/</url>
  <inceptionYear>2000</inceptionYear>
  <developers>
    <developer>
      <id>ebruneton</id>
      <name>Eric Bruneton</name>
      <email>Eric.Bruneton at rd.francetelecom.com</email>
      <roles>
        <role>Creator</role>
        <role>Java Developer</role>
      </roles>
    </developer>
    <developer>
      <id>eu</id>
      <name>Eugene Kuleshov</name>
      <email>eu at javatx.org</email>
      <roles>
        <role>Java Developer</role>
      </roles>
    </developer>
  </developers>
  <organization>
    <name>ObjectWeb</name>
    <url>http://www.objectweb.org/</url>
  </organization>
  <build />
</project>
--- NEW FILE: asm-component-info.xml ---
<project name="asm-component-info">

   <component id="asm"
              licenseType="bsd"
              version="@VERSION@"
              projectHome="http://asm.objectweb.org/"
              description="A very small and fast Java bytecode manipulation framework"
              tag="@TAG@">
      <artifact id="asm.jar"/>
      <artifact id="asm-attrs.jar"/>
      <export>
         <include input="asm.jar"/>
         <include input="asm-attrs.jar"/>
      </export>
   </component>


</project>

--- NEW FILE: sources ---
f110714252dc20243dec751df659e415  asm-1.5.3.tar.gz
5f17bfac3563feb108793575f74ce27c  asm-eng.pdf

--- NEW FILE: asm-xml-1.5.3.pom ---
<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>asm</groupId>
  <artifactId>asm-xml</artifactId>
  <name>asm-xml</name>
  <version>1.5.3</version>
  <url>http://asm.objectweb.org/</url>
  <inceptionYear>2000</inceptionYear>
  <developers>
    <developer>
      <id>ebruneton</id>
      <name>Eric Bruneton</name>
      <email>Eric.Bruneton at rd.francetelecom.com</email>
      <roles>
        <role>Creator</role>
        <role>Java Developer</role>
      </roles>
    </developer>
    <developer>
      <id>eu</id>
      <name>Eugene Kuleshov</name>
      <email>eu at javatx.org</email>
      <roles>
        <role>Java Developer</role>
      </roles>
    </developer>
  </developers>
  <organization>
    <name>ObjectWeb</name>
    <url>http://www.objectweb.org/</url>
  </organization>
  <build />
</project>
--- NEW FILE: asm-util-1.5.3.pom ---
<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>asm</groupId>
  <artifactId>asm-util</artifactId>
  <name>asm-util</name>
  <version>1.5.3</version>
  <url>http://asm.objectweb.org/</url>
  <inceptionYear>2000</inceptionYear>
  <developers>
    <developer>
      <id>ebruneton</id>
      <name>Eric Bruneton</name>
      <email>Eric.Bruneton at rd.francetelecom.com</email>
      <roles>
        <role>Creator</role>
        <role>Java Developer</role>
      </roles>
    </developer>
    <developer>
      <id>eu</id>
      <name>Eugene Kuleshov</name>
      <email>eu at javatx.org</email>
      <roles>
        <role>Java Developer</role>
      </roles>
    </developer>
  </developers>
  <organization>
    <name>ObjectWeb</name>
    <url>http://www.objectweb.org/</url>
  </organization>
  <build />
</project>
--- NEW FILE: asm-attrs-1.5.3.pom ---
<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>asm</groupId>
  <artifactId>asm-attrs</artifactId>
  <name>asm-attrs</name>
  <version>1.5.3</version>
  <url>http://asm.objectweb.org/</url>
  <inceptionYear>2000</inceptionYear>
  <developers>
    <developer>
      <id>ebruneton</id>
      <name>Eric Bruneton</name>
      <email>Eric.Bruneton at rd.francetelecom.com</email>
      <roles>
        <role>Creator</role>
        <role>Java Developer</role>
      </roles>
    </developer>
    <developer>
      <id>eu</id>
      <name>Eugene Kuleshov</name>
      <email>eu at javatx.org</email>
      <roles>
        <role>Java Developer</role>
      </roles>
    </developer>
  </developers>
  <organization>
    <name>ObjectWeb</name>
    <url>http://www.objectweb.org/</url>
  </organization>
  <build />
</project>
--- NEW FILE: faq.html ---
<!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 at objectweb.org">
<meta name="Owner" content="ObjectWeb">
<meta name="Robots" content="index, follow">
<meta content="asm-team" name="author">
<meta content="asm-team at 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 plugins</a>
<br>
        · <a class="menu" target="_self" href="http://www.objectweb.org/wws/lists/projects/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/cvs/?group_id=23">CVS Repository</a>
<br>
        · <a class="menu" target="_self" href="http://forge.objectweb.org/projects/asm/">ObjectWeb Forge Site</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 at 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 at 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>
    
</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.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.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:</p>


<p>
<code>java -cp "asm.jar;asm-tree.jar;asm-analysis.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
visitLdc("Hello world!") with visitLdc(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.main(Unknown Source)
main([Ljava/lang/String;)V
00000 [Ljava/lang/String;.  :     GETSTATIC java/lang/System out Ljava/io/PrintStream;
00001 [Ljava/lang/String;. Ljava/io/PrintStream; :     LDC 1234
00002 [Ljava/lang/String;. Ljava/io/PrintStream;I :     INVOKEVIRTUAL java/io/PrintStream println (Ljava/lang/String;)V
00003 null  :     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). 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 cv = new ClassWriter(true);
  cv = new CheckClassAdapter(cv);
  // 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.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>


    
</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 at objectweb.org">webmaster</a> | Last modified at 2005-02-22 05:27 PM</address>
</td><td valign="top" width="10"><img alt=" " height="1" width="10" src="../images/pix.gif"></td>
</tr>
</table>
<br>
</body>
</html>




More information about the JPackage-commits mailing list