Search in sources :

Example 1 with SimpleClassMetadata

use of com.navercorp.pinpoint.profiler.instrument.classreading.SimpleClassMetadata in project pinpoint by naver.

the class PlainClassLoaderHandler method define0.

private void define0(final ClassLoader classLoader, ClassLoaderAttachment attachment, SimpleClassMetadata currentClass, Map<String, SimpleClassMetadata> classMetaMap, ClassLoadingChecker classLoadingChecker) {
    if ("java.lang.Object".equals(currentClass.getClassName())) {
        return;
    }
    if (attachment.containsClass(currentClass.getClassName())) {
        return;
    }
    final String superName = currentClass.getSuperClassName();
    if (isDebug) {
        logger.debug("className:{} super:{}", currentClass.getClassName(), superName);
    }
    if (!"java.lang.Object".equals(superName)) {
        if (!isSkipClass(superName, classLoadingChecker)) {
            SimpleClassMetadata superClassBinary = classMetaMap.get(superName);
            if (isDebug) {
                logger.debug("superClass dependency define super:{} ori:{}", superClassBinary.getClassName(), currentClass.getClassName());
            }
            define0(classLoader, attachment, superClassBinary, classMetaMap, classLoadingChecker);
        }
    }
    final List<String> interfaceList = currentClass.getInterfaceNames();
    for (String interfaceName : interfaceList) {
        if (!isSkipClass(interfaceName, classLoadingChecker)) {
            SimpleClassMetadata interfaceClassBinary = classMetaMap.get(interfaceName);
            if (interfaceClassBinary == null) {
                throw new PinpointException(interfaceName + " not found");
            }
            if (isDebug) {
                logger.debug("interface dependency define interface:{} ori:{}", interfaceClassBinary.getClassName(), interfaceClassBinary.getClassName());
            }
            define0(classLoader, attachment, interfaceClassBinary, classMetaMap, classLoadingChecker);
        }
    }
    final Class<?> clazz = defineClass(classLoader, currentClass);
    attachment.putClass(currentClass.getClassName(), clazz);
}
Also used : SimpleClassMetadata(com.navercorp.pinpoint.profiler.instrument.classreading.SimpleClassMetadata) PinpointException(com.navercorp.pinpoint.exception.PinpointException)

Example 2 with SimpleClassMetadata

use of com.navercorp.pinpoint.profiler.instrument.classreading.SimpleClassMetadata in project pinpoint by naver.

the class PlainClassLoaderHandler method defineJarClass.

private void defineJarClass(ClassLoader classLoader, ClassLoaderAttachment attachment) {
    if (isDebug) {
        logger.debug("define Jar:{}", pluginConfig.getPluginJarURLExternalForm());
    }
    List<FileBinary> fileBinaryList = readJar();
    Map<String, SimpleClassMetadata> classEntryMap = parse(fileBinaryList);
    for (Map.Entry<String, SimpleClassMetadata> entry : classEntryMap.entrySet()) {
        final SimpleClassMetadata classMetadata = entry.getValue();
        ClassLoadingChecker classLoadingChecker = new ClassLoadingChecker();
        classLoadingChecker.isFirstLoad(classMetadata.getClassName());
        define0(classLoader, attachment, classMetadata, classEntryMap, classLoadingChecker);
    }
}
Also used : SimpleClassMetadata(com.navercorp.pinpoint.profiler.instrument.classreading.SimpleClassMetadata) FileBinary(com.navercorp.pinpoint.profiler.util.FileBinary) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) ConcurrentWeakHashMap(com.navercorp.pinpoint.common.profiler.concurrent.jsr166.ConcurrentWeakHashMap) ClassLoadingChecker(com.navercorp.pinpoint.profiler.plugin.ClassLoadingChecker)

Example 3 with SimpleClassMetadata

use of com.navercorp.pinpoint.profiler.instrument.classreading.SimpleClassMetadata in project pinpoint by naver.

the class PlainClassLoaderHandler method parse.

private Map<String, SimpleClassMetadata> parse(List<FileBinary> fileBinaryList) {
    Map<String, SimpleClassMetadata> parseMap = new HashMap<>();
    for (FileBinary fileBinary : fileBinaryList) {
        SimpleClassMetadata classNode = parseClass(fileBinary);
        parseMap.put(classNode.getClassName(), classNode);
    }
    return parseMap;
}
Also used : SimpleClassMetadata(com.navercorp.pinpoint.profiler.instrument.classreading.SimpleClassMetadata) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentWeakHashMap(com.navercorp.pinpoint.common.profiler.concurrent.jsr166.ConcurrentWeakHashMap) FileBinary(com.navercorp.pinpoint.profiler.util.FileBinary)

Example 4 with SimpleClassMetadata

use of com.navercorp.pinpoint.profiler.instrument.classreading.SimpleClassMetadata in project pinpoint by naver.

the class PlainClassLoaderHandler method parseClass.

private SimpleClassMetadata parseClass(FileBinary fileBinary) {
    byte[] fileBinaryArray = fileBinary.getFileBinary();
    SimpleClassMetadata classMetadata = SimpleClassMetadataReader.readSimpleClassMetadata(fileBinaryArray);
    return classMetadata;
}
Also used : SimpleClassMetadata(com.navercorp.pinpoint.profiler.instrument.classreading.SimpleClassMetadata)

Aggregations

SimpleClassMetadata (com.navercorp.pinpoint.profiler.instrument.classreading.SimpleClassMetadata)4 ConcurrentWeakHashMap (com.navercorp.pinpoint.common.profiler.concurrent.jsr166.ConcurrentWeakHashMap)2 FileBinary (com.navercorp.pinpoint.profiler.util.FileBinary)2 HashMap (java.util.HashMap)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 PinpointException (com.navercorp.pinpoint.exception.PinpointException)1 ClassLoadingChecker (com.navercorp.pinpoint.profiler.plugin.ClassLoadingChecker)1 Map (java.util.Map)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1