]> source.dussan.org Git - javassist.git/commitdiff
fixed JIRA JASSIST-25
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Sun, 6 Aug 2006 15:09:45 +0000 (15:09 +0000)
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Sun, 6 Aug 2006 15:09:45 +0000 (15:09 +0000)
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@304 30ef5769-5b8d-40dd-aea6-55b5d6557bb3

src/main/javassist/CtClassType.java

index ab0d07ede316f79ccfe26570a7b7cd30d0cb5b54..0ec764e45096c7572d92491655ce6aa701dbea7a 100644 (file)
@@ -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 {