aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/javassist/CtNewClass.java
diff options
context:
space:
mode:
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2009-04-04 15:41:55 +0000
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2009-04-04 15:41:55 +0000
commitc4b9da1f23695844fc4535ad6b79c0eb59191ae1 (patch)
treef9b15b318d9a40505aa8ee22015b33849993a378 /src/main/javassist/CtNewClass.java
parentbead430f64ef930897dc4d25c36b854fec2d3092 (diff)
downloadjavassist-c4b9da1f23695844fc4535ad6b79c0eb59191ae1.tar.gz
javassist-c4b9da1f23695844fc4535ad6b79c0eb59191ae1.zip
for fixing JASSIST-68
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@474 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/main/javassist/CtNewClass.java')
-rw-r--r--src/main/javassist/CtNewClass.java20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/main/javassist/CtNewClass.java b/src/main/javassist/CtNewClass.java
index a95414af..2229d417 100644
--- a/src/main/javassist/CtNewClass.java
+++ b/src/main/javassist/CtNewClass.java
@@ -90,10 +90,12 @@ class CtNewClass extends CtClassType {
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 @@ class CtNewClass extends CtClassType {
"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;
+ }
}