[jboss-jira] [JBoss JIRA] Closed: (JASSIST-25) RuntimeException: cannot set to static - when calling CtClassType.setModifiers(int mod)
Shigeru Chiba (JIRA)
jira-events at jboss.com
Sun Aug 6 11:16:13 EDT 2006
[ http://jira.jboss.com/jira/browse/JASSIST-25?page=all ]
Shigeru Chiba closed JASSIST-25.
--------------------------------
> RuntimeException: cannot set to static - when calling CtClassType.setModifiers(int mod)
> ---------------------------------------------------------------------------------------
>
> Key: JASSIST-25
> URL: http://jira.jboss.com/jira/browse/JASSIST-25
> Project: Javassist
> Issue Type: Bug
> Environment: Windows XP SP2, Mac OS 10.4
> Reporter: Martin Burger
> Assigned To: Shigeru Chiba
>
> Hello!
> I wrote a class that removes final modifier from given classes, here's the most relevant method:
> Code:
> public void instrument(CtClass clazz) {
> int modifiers = clazz.getModifiers();
> if (Modifier.isFinal(modifiers)) {
> logger.info("Will remove final modifier from class: " + clazz.getName());
> logger.debug("Old modifiers: " + Modifier.toString(modifiers));
> int newModifiers = Modifier.clear(modifiers, Modifier.FINAL);
> logger.debug("New modifiers: " + Modifier.toString(newModifiers));
> clazz.setModifiers(newModifiers);
> } else {
> logger.debug("Class is not final, nothing do change: " + clazz.getName());
> }
> }
> Running my util on the JDK classes results in an exception:
> Code:
> Exception in thread "main" java.lang.RuntimeException: cannot set to static
> at javassist.CtClassType.setModifiers(CtClassType.java:374)
> The last lines of my log are:
> Code:
> 307 [ main] TRACE mon.javassist.FileInstrumenter - Current jar entry: com/sun/corba/se
> /impl/corba/AnyImpl$AnyInputStream.class
> 307 [ main] INFO y.framework.utils.FinalRemover - Will remove final modifier from cla
> ss: com.sun.corba.se.impl.corba.AnyImpl$AnyInputStream
> 308 [ main] DEBUG y.framework.utils.FinalRemover - Old modifiers: static final
> 308 [ main] DEBUG y.framework.utils.FinalRemover - New modifiers: static
> The class CtClassType contains the following lines:
> Code:
> public void setModifiers(int mod) {
> if (Modifier.isStatic(mod))
> throw new RuntimeException("cannot set to static");
> checkModify();
> int acc = AccessFlag.of(mod) | AccessFlag.SUPER;
> getClassFile2().setAccessFlags(acc);
> }
>
> So, why is it not possible to change the modifier from "static final" to "static"? AFAIK, static inner classes are allowed, aren't they?
> Regards, Martin
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list