private static void handleLdc()

in core/src/main/java/com/spotify/missinglink/ClassLoader.java [285:304]


  private static void handleLdc(Set<ClassTypeDescriptor> loadedClasses, LdcInsnNode insn) {
    // See http://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.ldc
    // if an LDC instruction is emitted with a symbolic reference to a class, that class is
    // loaded. This means we need to at least check for presence of that class, and also
    // validate its static initialisation code, if any. It would probably be safe for some
    // future to ignore other methods defined by the class.
    if (insn.cst instanceof Type) {
      Type type = (Type) insn.cst;

      Type loadedType = type;

      if (type.getSort() == Type.ARRAY) {
        loadedType = type.getElementType();
      }

      if (loadedType.getSort() == Type.OBJECT) {
        loadedClasses.add(TypeDescriptors.fromClassName(loadedType.getInternalName()));
      }
    }
  }