From f7ef31ce8b723e425a66aafb8c0beddeabfe9a66 Mon Sep 17 00:00:00 2001 From: chibash Date: Mon, 2 Sep 2019 01:08:17 +0900 Subject: [PATCH] fixes Issue #271 --- Readme.html | 2 +- src/main/javassist/ClassPool.java | 8 ++++++++ src/main/javassist/ClassPoolTail.java | 10 +++++++--- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Readme.html b/Readme.html index ae68ac6c..461c614a 100644 --- a/Readme.html +++ b/Readme.html @@ -283,7 +283,7 @@ see javassist.Dump.

-version 3.26

-version 3.25 on April 16, 2019 diff --git a/src/main/javassist/ClassPool.java b/src/main/javassist/ClassPool.java index 7d8cde08..326c643b 100644 --- a/src/main/javassist/ClassPool.java +++ b/src/main/javassist/ClassPool.java @@ -113,6 +113,14 @@ public class ClassPool { */ public static boolean releaseUnmodifiedClassFile = true; + /** + * If true, the contents of a jar file are cached after the jar + * file is opened. + * + *

The initial value is true. + */ + public static boolean cacheOpenedJarFile = true; // see ClassPoolTail.JarClassPath#openClassfile(String) + protected ClassPoolTail source; protected ClassPool parent; protected Hashtable classes; // should be synchronous diff --git a/src/main/javassist/ClassPoolTail.java b/src/main/javassist/ClassPoolTail.java index 965d72fb..d9d2198e 100644 --- a/src/main/javassist/ClassPoolTail.java +++ b/src/main/javassist/ClassPoolTail.java @@ -159,9 +159,13 @@ final class JarClassPath implements ClassPath { URL jarURL = find(classname); if (null != jarURL) try { - java.net.URLConnection con = jarURL.openConnection(); - con.setUseCaches(false); - return con.getInputStream(); + if (ClassPool.cacheOpenedJarFile) + return jarURL.openConnection().getInputStream(); + else { + java.net.URLConnection con = jarURL.openConnection(); + con.setUseCaches(false); + return con.getInputStream(); + } } catch (IOException e) { throw new NotFoundException("broken jar file?: " -- 2.39.5