From 855955bb3de853b165fd292468c40e20e179ecb1 Mon Sep 17 00:00:00 2001 From: dragonmacher <48328597+dragonmacher@users.noreply.github.com> Date: Mon, 24 Feb 2020 11:00:51 -0500 Subject: [PATCH] GT-3547 - Patch dir fix - review fixes --- .../ghidra/util/classfinder/ClassJar.java | 18 +++++++++------- .../src/main/java/ghidra/GhidraLauncher.java | 4 ++-- GhidraBuild/patch/README.txt | 21 +++++++++---------- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/Ghidra/Framework/Generic/src/main/java/ghidra/util/classfinder/ClassJar.java b/Ghidra/Framework/Generic/src/main/java/ghidra/util/classfinder/ClassJar.java index 96da614379..48b9be6f14 100644 --- a/Ghidra/Framework/Generic/src/main/java/ghidra/util/classfinder/ClassJar.java +++ b/Ghidra/Framework/Generic/src/main/java/ghidra/util/classfinder/ClassJar.java @@ -94,21 +94,24 @@ class ClassJar extends ClassLocation { // // - // Dev Mode + // Dev Mode - don't scan 3rd-party jar files // if (pathName.contains("ExternalLibraries")) { return true; } // - // Dev and Production Mode - // - String forwardSlashedPathName = pathName.replaceAll("\\\\", "/"); - if (isUserPluginJar(forwardSlashedPathName)) { + // Dev Mode - let everything else through + // + if (SystemUtilities.isInDevelopmentMode()) { return false; } - if (SystemUtilities.isInDevelopmentMode()) { + // + // Production Mode - old style (before Extensions) of user contributions + // + String forwardSlashedPathName = pathName.replaceAll("\\\\", "/"); + if (isUserPluginJar(forwardSlashedPathName)) { return false; } @@ -120,12 +123,13 @@ class ClassJar extends ClassLocation { } // - // Production Mode - In production, only module lib jar files are scanned. + // Production Mode - In production, only module lib jar files are scanned // if (isModuleDependencyJar(forwardSlashedPathName)) { return false; } + // this is typically a 3rd-party jar file return true; } diff --git a/Ghidra/Framework/Utility/src/main/java/ghidra/GhidraLauncher.java b/Ghidra/Framework/Utility/src/main/java/ghidra/GhidraLauncher.java index 40d0aaf7fa..8db165297e 100644 --- a/Ghidra/Framework/Utility/src/main/java/ghidra/GhidraLauncher.java +++ b/Ghidra/Framework/Utility/src/main/java/ghidra/GhidraLauncher.java @@ -87,10 +87,10 @@ public class GhidraLauncher { * the classpath. * * @param pathList The list of paths to add to - * @param patchDir The application installation directory + * @param patchDir The application installation directory; may be null */ private static void addPatchPaths(List pathList, ResourceFile patchDir) { - if (!patchDir.exists()) { + if (patchDir == null || !patchDir.exists()) { return; } diff --git a/GhidraBuild/patch/README.txt b/GhidraBuild/patch/README.txt index 70fbdca2c3..c49fd4483c 100644 --- a/GhidraBuild/patch/README.txt +++ b/GhidraBuild/patch/README.txt @@ -1,13 +1,12 @@ -Compiled Java class files, either inside of a jar file or in a directory structure may be inserted -into this directory. This directory and the contained jar files will be prepended to -the classpath, allowing them to override any existing classes in any module (except those from -the Utility module). - -The jar files will be sorted by name before being added to the classpath in order to present -predictable class loading between Ghidra runs. This directory will be prepended on the classpath -before any jar files, given the classes in this directory precedence over the jar files. - -The class files in this directory must be in a directory structure that matches their respective -packages. +This directory exits so that Ghidra releases can be patched, or overridden. +Classes or jar files placed in this directory will found and loaded +*before* the classes that exist in the release jar files. One exception +is that classes in the Utility module can not be patched in this way. +The jar files will be sorted by name before being prepended to the classpath +in order to have predictable class loading between Ghidra runs. This patch +directory will be the very first patch entry on the classpath such that any +individual classes will be found before classes in any of the patch jar files. +The class files in this directory must be in the standard java package +directory structure.