Example #1
0
  public CtClass[] getInterfaces() throws NotFoundException {
    if (interfaces == null) {
      Class[] intfs = Object[].class.getInterfaces();
      // java.lang.Cloneable and java.io.Serializable.
      // If the JVM is CLDC, intfs is empty.
      interfaces = new CtClass[intfs.length];
      for (int i = 0; i < intfs.length; i++) interfaces[i] = pool.get(intfs[i].getName());
    }

    return interfaces;
  }
Example #2
0
 private CtClass lookupClass0(String classname, boolean notCheckInner) throws NotFoundException {
   CtClass cc = null;
   do {
     try {
       cc = classPool.get(classname);
     } catch (NotFoundException e) {
       int i = classname.lastIndexOf('.');
       if (notCheckInner || i < 0) throw e;
       else {
         StringBuffer sbuf = new StringBuffer(classname);
         sbuf.setCharAt(i, '$');
         classname = sbuf.toString();
       }
     }
   } while (cc == null);
   return cc;
 }
Example #3
0
  private CtClass searchImports(String orgName) throws CompileError {
    if (orgName.indexOf('.') < 0) {
      Iterator it = classPool.getImportedPackages();
      while (it.hasNext()) {
        String pac = (String) it.next();
        String fqName = pac + '.' + orgName;
        try {
          CtClass cc = classPool.get(fqName);
          // if the class is found,
          classPool.recordInvalidClassName(orgName);
          return cc;
        } catch (NotFoundException e) {
          classPool.recordInvalidClassName(fqName);
        }
      }
    }

    throw new CompileError("no such class: " + orgName);
  }
Example #4
0
 public CtClass getSuperclass() throws NotFoundException {
   return pool.get(javaLangObject);
 }
Example #5
0
 public CtClass getComponentType() throws NotFoundException {
   String name = getName();
   return pool.get(name.substring(0, name.length() - 2));
 }