protected void copyExistingJarEntries()

in disco-java-agent-instrumentation-preprocess/src/main/java/software/amazon/disco/instrumentation/preprocess/export/JarExportStrategy.java [119:138]


    protected void copyExistingJarEntries(final JarOutputStream jarOS, final JarFile jarFile, final Map<String, InstrumentedClassState> instrumented) {
        log.info(PreprocessConstants.MESSAGE_PREFIX + "Copying existing entries from file: " + jarFile.getName());
        final Enumeration entries = jarFile.entries();
        while (entries.hasMoreElements()) {
            final JarEntry entry = (JarEntry) entries.nextElement();
            final String keyToCheck = entry.getName().endsWith(".class") ? entry.getName().substring(0, entry.getName().lastIndexOf(".class")) : entry.getName();

            try {
                if (!instrumented.containsKey(keyToCheck)) {
                    if (entry.isDirectory()) {
                        jarOS.putNextEntry(entry);
                    } else {
                        copyJarEntry(jarOS, jarFile, entry);
                    }
                }
            } catch (IOException e) {
                throw new ExportException("Failed to copy class: " + entry.getName(), e);
            }
        }
    }