[jboss-cvs] javassist/src/main/javassist ...
Shigeru Chiba
chiba at is.titech.ac.jp
Sat Apr 4 11:41:55 EDT 2009
User: chiba
Date: 09/04/04 11:41:55
Modified: src/main/javassist CtNewClass.java ClassPool.java
Log:
for fixing JASSIST-68
Revision Changes Path
1.14 +19 -1 javassist/src/main/javassist/CtNewClass.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CtNewClass.java
===================================================================
RCS file: /cvsroot/jboss/javassist/src/main/javassist/CtNewClass.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- CtNewClass.java 14 Aug 2007 02:08:01 -0000 1.13
+++ CtNewClass.java 4 Apr 2009 15:41:55 -0000 1.14
@@ -90,10 +90,12 @@
int n = 0;
for (int i = 0; i < cs.length; ++i) {
CtConstructor c = cs[i];
- if (Modifier.isPublic(c.getModifiers())) {
+ int mod = c.getModifiers();
+ if (isInheritable(mod, superclazz)) {
CtConstructor cons
= CtNewConstructor.make(c.getParameterTypes(),
c.getExceptionTypes(), this);
+ cons.setModifiers(mod & (Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE));
addConstructor(cons);
++n;
}
@@ -104,4 +106,20 @@
"no public constructor in " + superclazz.getName());
}
+
+ private boolean isInheritable(int mod, CtClass superclazz) {
+ if (Modifier.isPrivate(mod))
+ return false;
+
+ if (Modifier.isPackage(mod)) {
+ String pname = getPackageName();
+ String pname2 = superclazz.getPackageName();
+ if (pname == null)
+ return pname2 == null;
+ else
+ pname.equals(pname2);
+ }
+
+ return true;
+ }
}
1.68 +16 -0 javassist/src/main/javassist/ClassPool.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ClassPool.java
===================================================================
RCS file: /cvsroot/jboss/javassist/src/main/javassist/ClassPool.java,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -b -r1.67 -r1.68
--- ClassPool.java 11 Sep 2008 10:40:08 -0000 1.67
+++ ClassPool.java 4 Apr 2009 15:41:55 -0000 1.68
@@ -724,6 +724,14 @@
* If there already exists a class with the same name, the new class
* overwrites that previous class.
*
+ * <p>If no constructor is explicitly added to the created new
+ * class, Javassist generates constructors and adds it when
+ * the class file is generated. It generates a new constructor
+ * for each constructor of the super class. The new constructor
+ * takes the same set of parameters and invokes the
+ * corresponding constructor of the super class. All the received
+ * parameters are passed to it.
+ *
* @param classname a fully-qualified class name.
* @throws RuntimeException if the existing class is frozen.
*/
@@ -736,6 +744,14 @@
* If there already exists a class/interface with the same name,
* the new class overwrites that previous class.
*
+ * <p>If no constructor is explicitly added to the created new
+ * class, Javassist generates constructors and adds it when
+ * the class file is generated. It generates a new constructor
+ * for each constructor of the super class. The new constructor
+ * takes the same set of parameters and invokes the
+ * corresponding constructor of the super class. All the received
+ * parameters are passed to it.
+ *
* @param classname a fully-qualified class name.
* @param superclass the super class.
* @throws RuntimeException if the existing class is frozen.
More information about the jboss-cvs-commits
mailing list