Skip to content

Commits on Source 13

.idea/
bin/
eclipse-output/
target/
runtest/
html/
lib/
tmp/
.DS_Store
.classpath
......
Java bytecode engineering toolkit
### [Javassist version 3](http://www.javassist.org)
Copyright (C) 1999- by Shigeru Chiba, All rights reserved.
Copyright (C) 1999-2018 by Shigeru Chiba, All rights reserved.
Javassist (JAVA programming ASSISTant) makes Java bytecode manipulation
simple. It is a class library for editing bytecodes in Java; it enables Java
......
......@@ -7,7 +7,7 @@
<h1>Javassist version 3</h1>
<h3>Copyright (C) 1999-2016 by Shigeru Chiba, All rights reserved.</h3>
<h3>Copyright (C) 1999-2018 by Shigeru Chiba, All rights reserved.</h3>
<p><br></p>
......@@ -281,6 +281,27 @@ see javassist.Dump.
<h2>Changes</h2>
<p>-version 3.23.1 on July 2, 2018
<ul>
<li>Github pull issue #171.</li>
</ul>
</p>
<p>-version 3.23 on June 21, 2018
<ul>
<li>Fix leaking file handlers in ClassPool and removed ClassPath.close(). Github issue #165.
</ul>
</p>
<p>-version 3.22 on October 10, 2017
<ul>
<li>Java 9 supports.
<li>JIRA JASSIST-261.
</ul>
</p>
<p>-version 3.21 on October 4, 2016
<ul>
<li>JIRA JASSIST-244, 245, 248, 250, 255, 256, 259, 262.
......
......@@ -6,7 +6,7 @@
<project name="javassist" default="jar" basedir=".">
<property name="dist-version" value="javassist-3.21.0-GA"/>
<property name="dist-version" value="javassist-3.23.1-GA"/>
<property environment="env"/>
<property name="target.jar" value="javassist.jar"/>
......@@ -16,8 +16,9 @@
<property name="build.dir" value="${basedir}/target"/>
<property name="build.classes.dir" value="${build.dir}/classes"/>
<property name="test.src.dir" value="${basedir}/src/test"/>
<property name="test.lib.dir" value="${test.src.dir}/resources"/>
<property name="test.build.dir" value="${build.dir}/test-classes"/>
<property name="test.run.dir" value="${basedir}/runtest"/>
<property name="test.run.dir" value="${build.dir}/runtest"/>
<property name="test.reports.dir" value = "${build.dir}/test-output"/>
<property name="run.dir" value="${build.classes.dir}"/>
......@@ -32,13 +33,16 @@
<path id="test.compile.classpath">
<pathelement location="${build.classes.dir}"/>
<pathelement location="${lib.dir}/junit.jar"/>
<pathelement location="${lib.dir}/hamcrest.jar"/>
</path>
<property name="test.compile.classpath" refid="test.compile.classpath"/>
<path id="test.classpath">
<pathelement location="${test.build.dir}"/>
<pathelement location="${test.lib.dir}"/>
<pathelement location="${lib.dir}/junit.jar"/>
<pathelement location="${lib.dir}/hamcrest.jar"/>
<pathelement location="${build.classes.dir}"/>
</path>
......@@ -98,12 +102,32 @@
</target>
<target name="runtest" depends="jar,test-compile">
<copy file="${test.lib.dir}/empty.jar"
tofile="${test.lib.dir}/emptyorig.jar"
preservelastmodified="true" />
<junit fork="true" printsummary="true" dir="${test.run.dir}">
<jvmarg value="-XX:-FailOverToOldVerifier"/>
<classpath refid="test.classpath"/>
<formatter type="xml" extension=".xml"/>
<test name="javassist.JvstTest" outfile="TestLog" />
</junit>
<move file="${test.lib.dir}/emptyorig.jar"
tofile="${test.lib.dir}/empty.jar" />
</target>
<target name="runtest9" depends="jar,test-compile">
<copy file="${test.lib.dir}/empty.jar"
tofile="${test.lib.dir}/emptyorig.jar"
preservelastmodified="true" />
<junit fork="true" printsummary="true" dir="${test.run.dir}">
<jvmarg line="--add-opens java.base/java.lang=ALL-UNNAMED" />
<jvmarg value="-XX:-FailOverToOldVerifier"/>
<classpath refid="test.classpath"/>
<formatter type="xml" extension=".xml"/>
<test name="javassist.JvstTest" outfile="TestLog" />
</junit>
<move file="${test.lib.dir}/emptyorig.jar"
tofile="${test.lib.dir}/empty.jar" />
</target>
<target name="sample" depends="compile">
......@@ -209,7 +233,6 @@ Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.</i>]]></bottom>
<target name="clean">
<delete dir="html"/>
<delete dir="${test.run.dir}" />
<delete dir="${build.dir}"/>
<delete file="${target.jar}"/>
<delete file="${dist-version}.zip"/>
......
javassist (1:3.23.1-1) unstable; urgency=medium
* Team upload.
* New upstream release
- Refreshed the patches
- Depend on junit4 instead of junit
* Standards-Version updated to 4.2.1
* Switch to debhelper level 11
* Use salsa.debian.org Vcs-* URLs
-- Emmanuel Bourg <ebourg@apache.org> Fri, 05 Oct 2018 00:43:04 +0200
javassist (1:3.21.0-2) unstable; urgency=medium
* Team upload.
......
......@@ -8,22 +8,19 @@ Uploaders:
Build-Depends:
debhelper (>= 11),
default-jdk,
junit,
junit4,
libmaven-bundle-plugin-java,
libmaven-javadoc-plugin-java,
maven-debian-helper (>= 2.1)
Standards-Version: 4.1.4
Vcs-Git: https://anonscm.debian.org/git/pkg-java/javassist.git
Vcs-Browser: https://anonscm.debian.org/cgit/pkg-java/javassist.git
Standards-Version: 4.2.1
Vcs-Git: https://salsa.debian.org/java-team/javassist.git
Vcs-Browser: https://salsa.debian.org/java-team/javassist
Homepage: http://jboss-javassist.github.io/javassist/
Package: libjavassist-java
Architecture: all
Depends:
${maven:Depends},
${misc:Depends}
Suggests:
${maven:OptionalDepends}
Depends: ${maven:Depends}, ${misc:Depends}
Suggests: ${maven:OptionalDepends}
Description: library for editing bytecodes in Java
This library makes Java bytecode manipulation simple. It enables Java
programs to define a new class at runtime and to modify a class file
......
junit junit jar s/3\..*/3.x/ * *
junit junit jar s/.*/4.x/ * *
......@@ -10,7 +10,7 @@ Forwarded: not-needed
--- a/src/test/javassist/JvstTest4.java
+++ b/src/test/javassist/JvstTest4.java
@@ -621,7 +621,7 @@
@@ -646,7 +646,7 @@
}
}
......@@ -19,7 +19,7 @@ Forwarded: not-needed
ClassPool pool = new ClassPool(true);
for(int paths=0; paths<50; paths++) {
pool.appendClassPath(JAVASSIST_JAR);
@@ -668,7 +668,7 @@
@@ -693,7 +693,7 @@
assertTrue("performance test (the next try may succeed): " + t2 + " < 6 * " + t1,
t2 < t1 * 6);
assertTrue(t3 + " < 3 * " + t1, t3 < t1 * 3);
......
From: Markus Koschany <apo@debian.org>
Date: Sun, 22 Apr 2018 22:08:06 +0200
Subject: java9
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=893196
---
pom.xml | 39 ---------------------------------------
1 file changed, 39 deletions(-)
diff --git a/pom.xml b/pom.xml
index 49ba665..5a8871c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -263,45 +263,6 @@
</plugins>
</build>
</profile>
- <!-- profiles to add tools jar containing com.sun.jdi code
- needed by sample code
- -->
- <profile>
- <id>default-tools</id>
- <activation>
- <os>
- <family>!mac</family>
- </os>
- </activation>
- <dependencies>
- <dependency>
- <groupId>com.sun</groupId>
- <artifactId>tools</artifactId>
- <version>${java.version}</version>
- <scope>system</scope>
- <optional>true</optional>
- <systemPath>${java.home}/../lib/tools.jar</systemPath>
- </dependency>
- </dependencies>
- </profile>
- <profile>
- <id>mac-tools</id>
- <activation>
- <os>
- <family>mac</family>
- </os>
- </activation>
- <dependencies>
- <dependency>
- <groupId>com.sun</groupId>
- <artifactId>tools</artifactId>
- <version>${java.version}</version>
- <scope>system</scope>
- <optional>true</optional>
- <systemPath>${java.home}/../lib/tools.jar</systemPath>
- </dependency>
- </dependencies>
- </profile>
</profiles>
<dependencies>
<dependency>
disable-JIRA150-test.patch
java9.patch
......@@ -10,6 +10,3 @@ override_dh_auto_test:
override_dh_clean:
dh_clean
rm -Rf runtest *.jar
get-orig-source:
uscan --download-current-version --force-download --rename --repack --compression xz
version=3
opts=uversionmangle=s/_/./g \
version=4
opts=repack,compression=xz,uversionmangle=s/_/./g \
https://github.com/jboss-javassist/javassist/tags .*/archive/rel_([\d_]+)(?:_ga)?.tar.gz
......@@ -7,10 +7,13 @@
Javassist (JAVA programming ASSISTant) makes Java bytecode manipulation
simple. It is a class library for editing bytecodes in Java.
</description>
<version>3.21.0-GA</version>
<version>3.23.1-GA</version>
<name>Javassist</name>
<url>http://www.javassist.org/</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<organization>
<name>Shigeru Chiba, www.javassist.org</name>
</organization>
......@@ -137,6 +140,11 @@
<build>
<sourceDirectory>src/main/</sourceDirectory>
<testSourceDirectory>src/test/</testSourceDirectory>
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
......@@ -145,8 +153,8 @@
<configuration>
<source>1.6</source>
<target>1.6</target>
<testSource>1.8</testSource>
<testTarget>1.8</testTarget>
<testSource>1.9</testSource>
<testTarget>1.9</testTarget>
<testCompilerArgument>-parameters</testCompilerArgument>
</configuration>
</plugin>
......@@ -159,7 +167,10 @@
<include>javassist/JvstTest.java</include>
</includes>
<forkMode>once</forkMode>
<workingDirectory>runtest</workingDirectory>
<additionalClasspathElements>
<additionalClasspathElement>resources</additionalClasspathElement>
</additionalClasspathElements>
<workingDirectory>${project.build.directory}/runtest</workingDirectory>
</configuration>
</plugin>
<plugin>
......@@ -191,7 +202,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.7</version>
<version>3.0.0-M1</version>
<configuration>
<attach>true</attach>
</configuration>
......@@ -199,7 +210,7 @@
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.5.3</version>
<version>3.3.0</version>
<executions>
<execution>
<id>bundle-manifest</id>
......@@ -269,9 +280,7 @@
<profile>
<id>default-tools</id>
<activation>
<os>
<family>!mac</family>
</os>
<jdk>[,1.8]</jdk>
</activation>
<dependencies>
<dependency>
......@@ -285,11 +294,9 @@
</dependencies>
</profile>
<profile>
<id>mac-tools</id>
<id>java9-tools</id>
<activation>
<os>
<family>mac</family>
</os>
<jdk>[1.9,]</jdk>
</activation>
<dependencies>
<dependency>
......@@ -298,7 +305,7 @@
<version>${java.version}</version>
<scope>system</scope>
<optional>true</optional>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
<systemPath>${java.home}/lib/jrt-fs.jar</systemPath>
</dependency>
</dependencies>
</profile>
......@@ -307,7 +314,13 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
</dependencies>
......
Specification-Title: Javassist
Specification-Vendor: Shigeru Chiba, www.javassist.org
Specification-Version: 3.21.0-GA
Specification-Version: 3.23.1-GA
Main-Class: javassist.CtClass
......@@ -16,9 +16,10 @@
package javassist;
import java.io.*;
import java.net.URL;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
/**
* A <code>ByteArrayClassPath</code> contains bytes that is served as
......@@ -62,11 +63,7 @@ public class ByteArrayClassPath implements ClassPath {
this.classfile = classfile;
}
/**
* Closes this class path.
*/
public void close() {}
@Override
public String toString() {
return "byte[]:" + classname;
}
......@@ -74,16 +71,17 @@ public class ByteArrayClassPath implements ClassPath {
/**
* Opens the class file.
*/
@Override
public InputStream openClassfile(String classname) {
if(this.classname.equals(classname))
return new ByteArrayInputStream(classfile);
else
return null;
}
/**
* Obtains the URL.
*/
@Override
public URL find(String classname) {
if(this.classname.equals(classname)) {
String cname = classname.replace('.', '/') + ".class";
......
......@@ -22,13 +22,16 @@ import javassist.compiler.CompileError;
* Thrown when bytecode transformation has failed.
*/
public class CannotCompileException extends Exception {
/** default serialVersionUID */
private static final long serialVersionUID = 1L;
private Throwable myCause;
/**
* Gets the cause of this throwable.
* It is for JDK 1.3 compatibility.
*/
public Throwable getCause() {
@Override
public synchronized Throwable getCause() {
return (myCause == this ? null : myCause);
}
......@@ -36,6 +39,7 @@ public class CannotCompileException extends Exception {
* Initializes the cause of this throwable.
* It is for JDK 1.3 compatibility.
*/
@Override
public synchronized Throwable initCause(Throwable cause) {
myCause = cause;
return this;
......@@ -49,7 +53,6 @@ public class CannotCompileException extends Exception {
public String getReason() {
if (message != null)
return message;
else
return this.toString();
}
......
......@@ -38,12 +38,16 @@ import java.net.URL;
* <code>ClassClassPath</code> uses a class object representing
* the class including the code snippet above.
*
* <p>Class files in a named module are private to that module.
* This method cannot obtain class files in named modules.
* </p>
*
* @see ClassPool#insertClassPath(ClassPath)
* @see ClassPool#appendClassPath(ClassPath)
* @see LoaderClassPath
*/
public class ClassClassPath implements ClassPath {
private Class thisClass;
private Class<?> thisClass;
/** Creates a search path.
*
......@@ -51,7 +55,7 @@ public class ClassClassPath implements ClassPath {
* file. <code>getResourceAsStream()</code> is called on
* this object.
*/
public ClassClassPath(Class c) {
public ClassClassPath(Class<?> c) {
thisClass = c;
}
......@@ -70,9 +74,10 @@ public class ClassClassPath implements ClassPath {
/**
* Obtains a class file by <code>getResourceAsStream()</code>.
*/
public InputStream openClassfile(String classname) {
String jarname = "/" + classname.replace('.', '/') + ".class";
return thisClass.getResourceAsStream(jarname);
@Override
public InputStream openClassfile(String classname) throws NotFoundException {
String filename = '/' + classname.replace('.', '/') + ".class";
return thisClass.getResourceAsStream(filename);
}
/**
......@@ -80,17 +85,13 @@ public class ClassClassPath implements ClassPath {
*
* @return null if the class file could not be found.
*/
@Override
public URL find(String classname) {
String jarname = "/" + classname.replace('.', '/') + ".class";
return thisClass.getResource(jarname);
}
/**
* Does nothing.
*/
public void close() {
String filename = '/' + classname.replace('.', '/') + ".class";
return thisClass.getResource(filename);
}
@Override
public String toString() {
return thisClass.getName() + ".class";
}
......
......@@ -16,6 +16,8 @@
package javassist;
import java.util.HashMap;
import javassist.bytecode.Descriptor;
/**
......@@ -47,7 +49,9 @@ import javassist.bytecode.Descriptor;
* @see CtClass#replaceClassName(ClassMap)
* @see CtNewMethod#copy(CtMethod,String,CtClass,ClassMap)
*/
public class ClassMap extends java.util.HashMap {
public class ClassMap extends HashMap<String,String> {
/** default serialVersionUID */
private static final long serialVersionUID = 1L;
private ClassMap parent;
/**
......@@ -89,14 +93,16 @@ public class ClassMap extends java.util.HashMap {
* @param newname the substituted class name.
* @see #fix(String)
*/
public void put(String oldname, String newname) {
@Override
public String put(String oldname, String newname) {
if (oldname == newname)
return;
return oldname;
String oldname2 = toJvmName(oldname);
String s = (String)get(oldname2);
String s = get(oldname2);
if (s == null || !s.equals(oldname2))
super.put(oldname2, toJvmName(newname));
return super.put(oldname2, toJvmName(newname));
return s;
}
/**
......@@ -113,13 +119,13 @@ public class ClassMap extends java.util.HashMap {
return;
String oldname2 = toJvmName(oldname);
String s = (String)get(oldname2);
String s = get(oldname2);
if (s == null)
super.put(oldname2, toJvmName(newname));
}
protected final void put0(Object oldname, Object newname) {
super.put(oldname, newname);
protected final String put0(String oldname, String newname) {
return super.put(oldname, newname);
}
/**
......@@ -132,14 +138,13 @@ public class ClassMap extends java.util.HashMap {
* @see #toJvmName(String)
* @see #toJavaName(String)
*/
public Object get(Object jvmClassName) {
Object found = super.get(jvmClassName);
@Override
public String get(Object jvmClassName) {
String found = super.get(jvmClassName);
if (found == null && parent != null)
return parent.get(jvmClassName);
else
return found;
}
/**
* Prevents a mapping from the specified class name to another name.
*/
......
......@@ -58,11 +58,4 @@ public interface ClassPath {
* @return null if the specified class file could not be found.
*/
URL find(String classname);
/**
* This method is invoked when the <code>ClassPath</code> object is
* detached from the search path. It will be an empty method in most of
* classes.
*/
void close();
}
......@@ -21,19 +21,16 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Method;
import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.security.ProtectionDomain;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import javassist.bytecode.ClassFile;
import javassist.bytecode.Descriptor;
import javassist.util.proxy.DefinePackageHelper;
/**
* A container of <code>CtClass</code> objects.
......@@ -69,36 +66,8 @@ import javassist.bytecode.Descriptor;
* @see javassist.CtClass
* @see javassist.ClassPath
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public class ClassPool {
// used by toClass().
private static java.lang.reflect.Method defineClass1, defineClass2;
private static java.lang.reflect.Method definePackage;
static {
try {
AccessController.doPrivileged(new PrivilegedExceptionAction(){
public Object run() throws Exception{
Class cl = Class.forName("java.lang.ClassLoader");
defineClass1 = cl.getDeclaredMethod("defineClass",
new Class[] { String.class, byte[].class,
int.class, int.class });
defineClass2 = cl.getDeclaredMethod("defineClass",
new Class[] { String.class, byte[].class,
int.class, int.class, ProtectionDomain.class });
definePackage = cl.getDeclaredMethod("definePackage",
new Class[] { String.class, String.class, String.class,
String.class, String.class, String.class,
String.class, java.net.URL.class });
return null;
}
});
}
catch (PrivilegedActionException pae) {
throw new RuntimeException("cannot initialize ClassPool", pae.getException());
}
}
/**
* Determines the search order.
......@@ -220,7 +189,8 @@ public class ClassPool {
* </pre>
*
* <p>If the default class pool cannot find any class files,
* try <code>ClassClassPath</code> and <code>LoaderClassPath</code>.
* try <code>ClassClassPath</code>, <code>ModuleClassPath</code>,
* or <code>LoaderClassPath</code>.
*
* @see ClassClassPath
* @see LoaderClassPath
......@@ -328,7 +298,7 @@ public class ClassPool {
* @see #importPackage(String)
* @since 3.1
*/
public Iterator getImportedPackages() {
public Iterator<String> getImportedPackages() {
return importedPackages.iterator();
}
......@@ -871,7 +841,7 @@ public class ClassPool {
*/
synchronized CtClass makeNestedClass(String classname) {
checkNotFrozen(classname);
CtClass clazz = new CtNewNestedClass(classname, this, false, null);
CtClass clazz = new CtNewClass(classname, this, false, null);
cacheCtClass(classname, clazz, true);
return clazz;
}
......@@ -1147,46 +1117,14 @@ public class ClassPool {
throws CannotCompileException
{
try {
byte[] b = ct.toBytecode();
java.lang.reflect.Method method;
Object[] args;
if (domain == null) {
method = defineClass1;
args = new Object[] { ct.getName(), b, new Integer(0),
new Integer(b.length)};
}
else {
method = defineClass2;
args = new Object[] { ct.getName(), b, new Integer(0),
new Integer(b.length), domain};
}
return (Class)toClass2(method, loader, args);
return javassist.util.proxy.DefineClassHelper.toClass(ct.getName(),
loader, domain, ct.toBytecode());
}
catch (RuntimeException e) {
throw e;
}
catch (java.lang.reflect.InvocationTargetException e) {
throw new CannotCompileException(e.getTargetException());
}
catch (Exception e) {
catch (IOException e) {
throw new CannotCompileException(e);
}
}
private static synchronized Object toClass2(Method method,
ClassLoader loader, Object[] args)
throws Exception
{
method.setAccessible(true);
try {
return method.invoke(loader, args);
}
finally {
method.setAccessible(false);
}
}
/**
* Defines a new package. If the package is already defined, this method
* performs nothing.
......@@ -1194,7 +1132,13 @@ public class ClassPool {
* <p>You do not necessarily need to
* call this method. If this method is called, then
* <code>getPackage()</code> on the <code>Class</code> object returned
* by <code>toClass()</code> will return a non-null object.
* by <code>toClass()</code> will return a non-null object.</p>
*
* <p>The jigsaw module introduced by Java 9 has broken this method.
* In Java 9 or later, the VM argument
* <code>--add-opens java.base/java.lang=ALL-UNNAMED</code>
* has to be given to the JVM so that this method can run.
* </p>
*
* @param loader the class loader passed to <code>toClass()</code> or
* the default one obtained by <code>getClassLoader()</code>.
......@@ -1203,31 +1147,12 @@ public class ClassPool {
* @see #toClass(CtClass)
* @see CtClass#toClass()
* @since 3.16
* @deprecated
*/
public void makePackage(ClassLoader loader, String name)
throws CannotCompileException
{
Object[] args = new Object[] {
name, null, null, null, null, null, null, null };
Throwable t;
try {
toClass2(definePackage, loader, args);
return;
}
catch (java.lang.reflect.InvocationTargetException e) {
t = e.getTargetException();
if (t == null)
t = e;
else if (t instanceof IllegalArgumentException) {
// if the package is already defined, an IllegalArgumentException
// is thrown.
return;
}
}
catch (Exception e) {
t = e;
DefinePackageHelper.definePackage(name, loader);
}
throw new CannotCompileException(t);
}
}