コード例 #1
0
ファイル: TypeData.java プロジェクト: alpapad/HotswapAgent
 /** Finds the most specific common super class of the given classes by considering array types. */
 public static org.hotswap.agent.javassist.CtClass commonSuperClassEx(
     org.hotswap.agent.javassist.CtClass one, org.hotswap.agent.javassist.CtClass two)
     throws org.hotswap.agent.javassist.NotFoundException {
   if (one == two) {
     return one;
   } else if (one.isArray() && two.isArray()) {
     org.hotswap.agent.javassist.CtClass ele1 = one.getComponentType();
     org.hotswap.agent.javassist.CtClass ele2 = two.getComponentType();
     org.hotswap.agent.javassist.CtClass element = commonSuperClassEx(ele1, ele2);
     if (element == ele1) {
       return one;
     } else if (element == ele2) {
       return two;
     } else {
       return one.getClassPool()
           .get(element == null ? "java.lang.Object" : element.getName() + "[]");
     }
   } else if (one.isPrimitive() || two.isPrimitive()) {
     return null; // TOP
   } else if (one.isArray() || two.isArray()) {
     // two.isArray())
     return one.getClassPool().get("java.lang.Object");
   } else {
     return commonSuperClass(one, two);
   }
 }
コード例 #2
0
ファイル: TypeData.java プロジェクト: alpapad/HotswapAgent
    private String fixTypes2(
        ArrayList<TypeVar> scc, HashSet<String> lowersSet, org.hotswap.agent.javassist.ClassPool cp)
        throws org.hotswap.agent.javassist.NotFoundException {
      Iterator<String> it = lowersSet.iterator();
      if (lowersSet.size() == 0) {
        return null; // only NullType
      } else if (lowersSet.size() == 1) {
        return it.next();
      } else {
        org.hotswap.agent.javassist.CtClass cc = cp.get(it.next());
        while (it.hasNext()) {
          cc = commonSuperClassEx(cc, cp.get(it.next()));
        }

        if (cc.getSuperclass() == null || isObjectArray(cc)) {
          cc = fixByUppers(scc, cp, new HashSet<TypeVar>(), cc);
        }

        if (cc.isArray()) {
          return org.hotswap.agent.javassist.bytecode.Descriptor.toJvmName(cc);
        } else {
          return cc.getName();
        }
      }
    }
コード例 #3
0
ファイル: TypeData.java プロジェクト: alpapad/HotswapAgent
 private static boolean isObjectArray(org.hotswap.agent.javassist.CtClass cc)
     throws org.hotswap.agent.javassist.NotFoundException {
   return cc.isArray() && cc.getComponentType().getSuperclass() == null;
 }