[jboss-cvs] javassist/src/main/javassist ...

Shigeru Chiba chiba at is.titech.ac.jp
Fri Apr 10 02:43:23 EDT 2009


  User: chiba   
  Date: 09/04/10 02:43:23

  Modified:    src/main/javassist  CtClassType.java
  Log:
  improved the runtime check by CtClass.addMethod()
  
  Revision  Changes    Path
  1.64      +10 -2     javassist/src/main/javassist/CtClassType.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CtClassType.java
  ===================================================================
  RCS file: /cvsroot/jboss/javassist/src/main/javassist/CtClassType.java,v
  retrieving revision 1.63
  retrieving revision 1.64
  diff -u -b -r1.63 -r1.64
  --- CtClassType.java	3 Jul 2008 07:56:24 -0000	1.63
  +++ CtClassType.java	10 Apr 2009 06:43:23 -0000	1.64
  @@ -1229,11 +1229,19 @@
       public void addMethod(CtMethod m) throws CannotCompileException {
           checkModify();
           if (m.getDeclaringClass() != this)
  -            throw new CannotCompileException("cannot add");
  +            throw new CannotCompileException("bad declaring class");
  +
  +        int mod = m.getModifiers();
  +        if ((getModifiers() & Modifier.INTERFACE) != 0) {
  +            m.setModifiers(mod | Modifier.PUBLIC);
  +            if ((mod & Modifier.ABSTRACT) == 0)
  +                throw new CannotCompileException(
  +                        "an interface method must be abstract: " + m.toString());
  +        }
   
           getMembers().addMethod(m);
           getClassFile2().addMethod(m.getMethodInfo2());
  -        if ((m.getModifiers() & Modifier.ABSTRACT) != 0)
  +        if ((mod & Modifier.ABSTRACT) != 0)
               setModifiers(getModifiers() | Modifier.ABSTRACT);
       }
   
  
  
  



More information about the jboss-cvs-commits mailing list