From: chiba Date: Sun, 6 Aug 2006 15:09:45 +0000 (+0000) Subject: fixed JIRA JASSIST-25 X-Git-Tag: rel_3_17_1_ga~328 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a62c5816078737cc3a392beaa88c2c03d95ea961;p=javassist.git fixed JIRA JASSIST-25 git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@304 30ef5769-5b8d-40dd-aea6-55b5d6557bb3 --- 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 {