aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/javassist/CtClassType.java12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/main/javassist/CtClassType.java b/src/main/javassist/CtClassType.java
index ab0d07ed..0ec764e4 100644
--- a/src/main/javassist/CtClassType.java
+++ b/src/main/javassist/CtClassType.java
@@ -404,12 +404,18 @@ class CtClassType extends CtClass {
}
public void setModifiers(int mod) {
- if (Modifier.isStatic(mod))
- throw new RuntimeException("cannot set to static");
+ ClassFile cf = getClassFile2();
+ if (Modifier.isStatic(mod)) {
+ int flags = cf.getInnerAccessFlags();
+ if (flags != -1 && (flags & AccessFlag.STATIC) != 0)
+ mod = mod & ~Modifier.STATIC;
+ else
+ throw new RuntimeException("cannot change " + getName() + " into a static class");
+ }
checkModify();
int acc = AccessFlag.of(mod) | AccessFlag.SUPER;
- getClassFile2().setAccessFlags(acc);
+ cf.setAccessFlags(acc);
}
public Object[] getAnnotations() throws ClassNotFoundException {