mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 02:39:44 +02:00
GP-0: Preventing duplicate classpath entries
This commit is contained in:
parent
d81f79ebb0
commit
0a13b80387
1 changed files with 10 additions and 0 deletions
|
@ -18,6 +18,8 @@ package ghidra;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.instrument.Instrumentation;
|
import java.lang.instrument.Instrumentation;
|
||||||
import java.net.*;
|
import java.net.*;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import ghidra.util.Msg;
|
import ghidra.util.Msg;
|
||||||
|
|
||||||
|
@ -49,6 +51,11 @@ public class GhidraClassLoader extends URLClassLoader {
|
||||||
*/
|
*/
|
||||||
public static final String CP_EXT = "java.class.path.ext";
|
public static final String CP_EXT = "java.class.path.ext";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to prevent duplicate URL's from being added to the classpath
|
||||||
|
*/
|
||||||
|
private Set<URL> alreadyAdded = new HashSet<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This one-argument constructor is required for the JVM to successfully use this class loader
|
* This one-argument constructor is required for the JVM to successfully use this class loader
|
||||||
* via the java.system.class.loader system property.
|
* via the java.system.class.loader system property.
|
||||||
|
@ -61,6 +68,9 @@ public class GhidraClassLoader extends URLClassLoader {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addURL(URL url) {
|
public void addURL(URL url) {
|
||||||
|
if (!alreadyAdded.add(url)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
super.addURL(url);
|
super.addURL(url);
|
||||||
try {
|
try {
|
||||||
System.setProperty(CP,
|
System.setProperty(CP,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue