aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--Readme.html4
-rw-r--r--build.xml2
-rw-r--r--javassist.jarbin723364 -> 724481 bytes
-rw-r--r--pom.xml4
-rw-r--r--sample/preproc/Assistant.java5
-rw-r--r--sample/preproc/Compiler.java5
-rw-r--r--src/main/META-INF/MANIFEST.MF2
-rw-r--r--src/main/javassist/SerialVersionUID.java4
-rw-r--r--src/main/javassist/bytecode/ClassFile.java5
-rw-r--r--src/main/javassist/compiler/MemberCodeGen.java13
-rw-r--r--src/main/javassist/compiler/MemberResolver.java39
-rw-r--r--src/main/javassist/tools/Callback.java14
-rw-r--r--src/test/javassist/JvstTest5.java38
-rw-r--r--src/test/test5/JIRA242.java25
-rw-r--r--src/test/test5/JIRA246.java21
16 files changed, 133 insertions, 50 deletions
diff --git a/README.md b/README.md
index 0fbb2d52..0ac01e5d 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
Java bytecode engineering toolkit
-### Javassist version 3
+### [Javassist version 3](http://www.javassist.org)
Copyright (C) 1999- by Shigeru Chiba, All rights reserved.
diff --git a/Readme.html b/Readme.html
index 0b9ea9eb..22e5480d 100644
--- a/Readme.html
+++ b/Readme.html
@@ -281,9 +281,9 @@ see javassist.Dump.
<h2>Changes</h2>
-<p>-version 3.20
+<p>-version 3.20 on June 25, 2015
<ul>
-<li>JIRA JASSIST-241
+<li>JIRA JASSIST-241, 242, 246.
</ul>
</p>
diff --git a/build.xml b/build.xml
index 01d3fdf0..b22829e0 100644
--- a/build.xml
+++ b/build.xml
@@ -6,7 +6,7 @@
<project name="javassist" default="jar" basedir=".">
- <property name="dist-version" value="javassist-3.19.0-GA"/>
+ <property name="dist-version" value="javassist-3.20.0-GA"/>
<property environment="env"/>
<property name="target.jar" value="javassist.jar"/>
diff --git a/javassist.jar b/javassist.jar
index 8fdba885..80e15002 100644
--- a/javassist.jar
+++ b/javassist.jar
Binary files differ
diff --git a/pom.xml b/pom.xml
index f76b823e..e76ccf67 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
Javassist (JAVA programming ASSISTant) makes Java bytecode manipulation
simple. It is a class library for editing bytecodes in Java.
</description>
- <version>3.19.0-GA</version>
+ <version>3.20.0-GA</version>
<name>Javassist</name>
<url>http://www.javassist.org/</url>
@@ -199,7 +199,7 @@
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
- <version>2.1.0</version>
+ <version>2.5.3</version>
<executions>
<execution>
<id>bundle-manifest</id>
diff --git a/sample/preproc/Assistant.java b/sample/preproc/Assistant.java
index 81b93b25..7ef15c4b 100644
--- a/sample/preproc/Assistant.java
+++ b/sample/preproc/Assistant.java
@@ -1,11 +1,12 @@
/*
* Javassist, a Java-bytecode translator toolkit.
- * Copyright (C) 1999-2005 Shigeru Chiba. All Rights Reserved.
+ * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. Alternatively, the contents of this file may be used under
- * the terms of the GNU Lesser General Public License Version 2.1 or later.
+ * the terms of the GNU Lesser General Public License Version 2.1 or later,
+ * or the Apache License Version 2.0.
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
diff --git a/sample/preproc/Compiler.java b/sample/preproc/Compiler.java
index 5481c0fc..085e09e0 100644
--- a/sample/preproc/Compiler.java
+++ b/sample/preproc/Compiler.java
@@ -1,11 +1,12 @@
/*
* Javassist, a Java-bytecode translator toolkit.
- * Copyright (C) 1999-2005 Shigeru Chiba. All Rights Reserved.
+ * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. Alternatively, the contents of this file may be used under
- * the terms of the GNU Lesser General Public License Version 2.1 or later.
+ * the terms of the GNU Lesser General Public License Version 2.1 or later,
+ * or the Apache License Version 2.0.
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
diff --git a/src/main/META-INF/MANIFEST.MF b/src/main/META-INF/MANIFEST.MF
index c7bad8e9..28b3763b 100644
--- a/src/main/META-INF/MANIFEST.MF
+++ b/src/main/META-INF/MANIFEST.MF
@@ -1,4 +1,4 @@
Specification-Title: Javassist
Specification-Vendor: Shigeru Chiba, www.javassist.org
-Specification-Version: 3.19.0-GA
+Specification-Version: 3.20.0-GA
Main-Class: javassist.CtClass
diff --git a/src/main/javassist/SerialVersionUID.java b/src/main/javassist/SerialVersionUID.java
index 1339af4e..c1a93bb6 100644
--- a/src/main/javassist/SerialVersionUID.java
+++ b/src/main/javassist/SerialVersionUID.java
@@ -70,8 +70,10 @@ public class SerialVersionUID {
/**
* Calculate default value. See Java Serialization Specification, Stream
* Unique Identifiers.
+ *
+ * @since 3.20
*/
- static long calculateDefault(CtClass clazz)
+ public static long calculateDefault(CtClass clazz)
throws CannotCompileException
{
try {
diff --git a/src/main/javassist/bytecode/ClassFile.java b/src/main/javassist/bytecode/ClassFile.java
index f27ff4d8..9e12c08d 100644
--- a/src/main/javassist/bytecode/ClassFile.java
+++ b/src/main/javassist/bytecode/ClassFile.java
@@ -30,7 +30,7 @@ import javassist.CannotCompileException;
* <code>ClassFile</code> represents a Java <code>.class</code> file, which
* consists of a constant pool, methods, fields, and attributes.
*
- * <p>For example,
+ * <p>For example,</p>
* <blockquote><pre>
* ClassFile cf = new ClassFile(false, "test.Foo", null);
* cf.setInterfaces(new String[] { "java.lang.Cloneable" });
@@ -41,14 +41,13 @@ import javassist.CannotCompileException;
*
* cf.write(new DataOutputStream(new FileOutputStream("Foo.class")));
* </pre></blockquote>
- * This code generates a class file <code>Foo.class</code> for the following class:
+ * <p>This code generates a class file <code>Foo.class</code> for the following class:</p>
* <blockquote><pre>
* package test;
* class Foo implements Cloneable {
* public int width;
* }
* </pre></blockquote>
- * </p>
*
* @see FieldInfo
* @see MethodInfo
diff --git a/src/main/javassist/compiler/MemberCodeGen.java b/src/main/javassist/compiler/MemberCodeGen.java
index f799eea0..67031992 100644
--- a/src/main/javassist/compiler/MemberCodeGen.java
+++ b/src/main/javassist/compiler/MemberCodeGen.java
@@ -568,9 +568,6 @@ public class MemberCodeGen extends CodeGen {
// generate code for evaluating arguments.
atMethodArgs(args, types, dims, cnames);
- // used by invokeinterface
- int count = bytecode.getStackDepth() - stack + 1;
-
if (found == null)
found = resolver.lookupMethod(targetClass, thisClass, thisMethod,
mname, types, dims, cnames);
@@ -587,12 +584,12 @@ public class MemberCodeGen extends CodeGen {
}
atMethodCallCore2(targetClass, mname, isStatic, isSpecial,
- aload0pos, count, found);
+ aload0pos, found);
}
private void atMethodCallCore2(CtClass targetClass, String mname,
boolean isStatic, boolean isSpecial,
- int aload0pos, int count,
+ int aload0pos,
MemberResolver.Method found)
throws CompileError
{
@@ -651,8 +648,10 @@ public class MemberCodeGen extends CodeGen {
|| declClass.isInterface() != targetClass.isInterface())
declClass = targetClass;
- if (declClass.isInterface())
- bytecode.addInvokeinterface(declClass, mname, desc, count);
+ if (declClass.isInterface()) {
+ int nargs = Descriptor.paramSize(desc) + 1;
+ bytecode.addInvokeinterface(declClass, mname, desc, nargs);
+ }
else
if (isStatic)
throw new CompileError(mname + " is not static");
diff --git a/src/main/javassist/compiler/MemberResolver.java b/src/main/javassist/compiler/MemberResolver.java
index c232ccda..ddbe1be4 100644
--- a/src/main/javassist/compiler/MemberResolver.java
+++ b/src/main/javassist/compiler/MemberResolver.java
@@ -139,30 +139,29 @@ public class MemberResolver implements TokenId {
}
catch (NotFoundException e) {}
- if (isIntf || Modifier.isAbstract(mod))
- try {
- CtClass[] ifs = clazz.getInterfaces();
- int size = ifs.length;
- for (int i = 0; i < size; ++i) {
- Method r = lookupMethod(ifs[i], methodName,
- argTypes, argDims, argClassNames,
- onlyExact);
+ try {
+ CtClass[] ifs = clazz.getInterfaces();
+ int size = ifs.length;
+ for (int i = 0; i < size; ++i) {
+ Method r = lookupMethod(ifs[i], methodName,
+ argTypes, argDims, argClassNames,
+ onlyExact);
+ if (r != null)
+ return r;
+ }
+
+ if (isIntf) {
+ // finally search java.lang.Object.
+ CtClass pclazz = clazz.getSuperclass();
+ if (pclazz != null) {
+ Method r = lookupMethod(pclazz, methodName, argTypes,
+ argDims, argClassNames, onlyExact);
if (r != null)
return r;
}
-
- if (isIntf) {
- // finally search java.lang.Object.
- CtClass pclazz = clazz.getSuperclass();
- if (pclazz != null) {
- Method r = lookupMethod(pclazz, methodName, argTypes,
- argDims, argClassNames, onlyExact);
- if (r != null)
- return r;
- }
- }
}
- catch (NotFoundException e) {}
+ }
+ catch (NotFoundException e) {}
return maybe;
}
diff --git a/src/main/javassist/tools/Callback.java b/src/main/javassist/tools/Callback.java
index 26a4200e..56c87414 100644
--- a/src/main/javassist/tools/Callback.java
+++ b/src/main/javassist/tools/Callback.java
@@ -25,26 +25,24 @@ import java.util.UUID;
/**
* Creates bytecode that when executed calls back to the instance's result method.
*
- * Example of how to create and insert a callback:
- * <pre>{@code
+ * <p>Example of how to create and insert a callback:</p>
+ * <pre>
* ctMethod.insertAfter(new Callback("Thread.currentThread()") {
- * @literal@Override
* public void result(Object... objects) {
* Thread thread = (Thread) objects[0];
* // do something with thread...
* }
* }.sourceCode());
- * }</pre>
- * Contains utility methods for inserts callbacks in <code>CtBehaviour</code>, example:
- * <pre>{@code
+ * </pre>
+ * <p>Contains utility methods for inserts callbacks in <code>CtBehaviour</code>, example:</p>
+ * <pre>
* insertAfter(ctBehaviour, new Callback("Thread.currentThread(), dummyString") {
- * @literal@Override
* public void result(Object... objects) {
* Thread thread = (Thread) objects[0];
* // do something with thread...
* }
* });
- * }</pre>
+ * </pre>
*
* @author Marten Hedborg
*/
diff --git a/src/test/javassist/JvstTest5.java b/src/test/javassist/JvstTest5.java
index 124f585d..fcbbbb99 100644
--- a/src/test/javassist/JvstTest5.java
+++ b/src/test/javassist/JvstTest5.java
@@ -53,4 +53,42 @@ public class JvstTest5 extends JvstTestRoot {
Object obj = make(cc.getName());
assertEquals(10, invoke(obj, "run"));
}
+
+ public void testJIRA246() throws Exception {
+ CtClass ctClass = sloader.makeClass("test5.JIRA246Test");
+ ctClass.addInterface(sloader.get(test5.JIRA246.Test.class.getName()));
+ String methodBody = "public void test() { defaultMethod(); }";
+ CtMethod ctMethod = CtMethod.make(methodBody, ctClass);
+ ctClass.addMethod(ctMethod);
+ }
+
+ public void testJIRA246b() throws Exception {
+ CtClass ctClass = sloader.get(test5.JIRA246.A.class.getName());
+ String src = "public void id() { get(); }";
+ CtMethod make = CtNewMethod.make(src, ctClass);
+ }
+
+ public void testJIRA242() throws Exception {
+ Boolean ss = new Boolean(2 > 3);
+ ClassPool cp = ClassPool.getDefault();
+ CtClass cc = cp.get("test5.JIRA242$Hello");
+ CtMethod m = cc.getDeclaredMethod("say");
+ m.insertBefore("{ System.out.println(\"Say Hello...\"); }");
+
+ StringBuilder sb = new StringBuilder();
+ sb.append("BOOL_SERIES = createBooleanSeriesStep();");
+ //Below code cause the issue
+ sb.append("BOOL_SERIES.setValue(3>=3);"); //lets comment this and run it will work
+ // Below code snippets will work
+ // this cast into exact class and call the same function
+ sb.append("((test5.JIRA242$BooleanDataSeries)BOOL_SERIES).setValue(3>=3);");
+ // this code snippet will set exact boolean variable to the function.
+ sb.append("boolean var = 3>=3;");
+ sb.append("BOOL_SERIES.setValue(var);");
+
+ m.insertBefore(sb.toString());
+ cc.writeFile();
+ Object obj = make(cc.getName());
+ assertEquals(0, invoke(obj, "say"));
+ }
}
diff --git a/src/test/test5/JIRA242.java b/src/test/test5/JIRA242.java
new file mode 100644
index 00000000..312e594c
--- /dev/null
+++ b/src/test/test5/JIRA242.java
@@ -0,0 +1,25 @@
+package test5;
+
+public class JIRA242 {
+ static interface IBooleanSeries {
+ public void setValue(boolean value);
+ }
+
+ public static class BooleanDataSeries implements IBooleanSeries{
+ @Override
+ public void setValue(boolean value) {}
+ }
+
+ public static class Hello {
+ IBooleanSeries BOOL_SERIES;
+
+ public int say() {
+ System.out.println("Hello end :) ");
+ return 0;
+ }
+
+ public IBooleanSeries createBooleanSeriesStep() {
+ return new BooleanDataSeries();
+ }
+ }
+}
diff --git a/src/test/test5/JIRA246.java b/src/test/test5/JIRA246.java
new file mode 100644
index 00000000..da23f6ea
--- /dev/null
+++ b/src/test/test5/JIRA246.java
@@ -0,0 +1,21 @@
+package test5;
+
+public class JIRA246 {
+ public interface Test {
+ default void defaultMethod() {
+ }
+ void test();
+ }
+
+ public interface IA {
+ default int get() {
+ return 0;
+ }
+ }
+
+ public static class A implements IA {
+ public int anotherGet() {
+ return 1;
+ }
+ }
+}