Skip to content

Commit 1074e9a

Browse files
bvfalconskybber
authored andcommitted
Adapt to GlassFish 7
1 parent 2df6bf6 commit 1074e9a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

plugin/hotswap-agent-glassfish-plugin/src/main/java/org/hotswap/agent/plugin/glassfish/WebappClassLoaderTransformer.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,18 @@ public class WebappClassLoaderTransformer {
3535
public static void patchWebappClassLoader(ClassPool classPool,CtClass ctClass) throws CannotCompileException, NotFoundException {
3636
if (!webappClassLoaderPatched) {
3737
try {
38+
String cacheFieldName = "resourceEntries";
39+
try {
40+
ctClass.getDeclaredField(cacheFieldName);
41+
} catch (NotFoundException e) {
42+
cacheFieldName = "resourceEntryCache";
43+
}
3844
// clear classloader cache
3945
ctClass.getDeclaredMethod("getResource", new CtClass[]{classPool.get("java.lang.String")}).insertBefore(
40-
"resourceEntries.clear();"
46+
cacheFieldName + ".clear();"
4147
);
4248
ctClass.getDeclaredMethod("getResourceAsStream", new CtClass[]{classPool.get("java.lang.String")}).insertBefore(
43-
"resourceEntries.clear();"
49+
cacheFieldName + ".clear();"
4450
);
4551
webappClassLoaderPatched = true;
4652
} catch (NotFoundException e) {

0 commit comments

Comments
 (0)