protected JarInfo loadJar()

in disco-java-agent-instrumentation-preprocess/src/main/java/software/amazon/disco/instrumentation/preprocess/loaders/classfiles/JarLoader.java [77:105]


    protected JarInfo loadJar(final File file, final ExportStrategy strategy) {
        log.info(PreprocessConstants.MESSAGE_PREFIX + "Loading module: " + file.getAbsolutePath());

        try (JarFile jarFile = new JarFile(file)) {
            final Map<String, byte[]> types = new HashMap<>();

            if (jarFile == null) {
                log.error(PreprocessConstants.MESSAGE_PREFIX + "Failed to load module: "+file.getAbsolutePath());
                return null;
            }

            injectFileToSystemClassPath(file);

            log.info(PreprocessConstants.MESSAGE_PREFIX + "Module loaded");

            for (JarEntry entry : extractEntries(jarFile)) {
                if (entry.getName().endsWith(".class")) {
                    final String nameWithoutExtension = entry.getName().substring(0, entry.getName().lastIndexOf(".class")).replace('/', '.');

                    types.put(nameWithoutExtension, JarFileUtils.readEntryFromJar(jarFile, entry));
                }
            }

            return types.isEmpty() ? null : new JarInfo(file, strategy, types);
        } catch (IOException e) {
            log.error(PreprocessConstants.MESSAGE_PREFIX + "Invalid file, skipped", e);
            return null;
        }
    }