From 0f5a0e592bd508a207a936871bee5101863f7cc6 Mon Sep 17 00:00:00 2001 From: Ryan Kurtz Date: Wed, 5 Aug 2026 09:04:35 -0400 Subject: [PATCH] GP-7104: Deprecated fixes --- .../DebuggerStaticMappingProviderTest.java | 54 +++++++++---------- .../DBTraceGuestPlatformMappedMemory.java | 7 +-- .../AbstractDBTraceProgramViewMemory.java | 5 -- .../datastruct/PrivatelyQueuedListener.java | 6 +-- .../examples/graph/SampleGraphProvider.java | 4 +- .../bsim/query/BSimClientFactory.java | 15 +++--- .../BSimPostgresDBConnectionManager.java | 2 +- .../features/bsim/query/BSimServerInfo.java | 5 +- .../features/bsim/query/FunctionDatabase.java | 2 +- .../client/PostgresFunctionDatabase.java | 2 +- .../bsim/query/elastic/ElasticConnection.java | 33 +++++++++--- .../facade/SimilarFunctionQueryService.java | 8 +-- .../query/file/H2FileFunctionDatabase.java | 2 +- .../bsim/query/ingest/BSimLaunchable.java | 5 +- .../facade/FunctionDatabaseTestDouble.java | 7 ++- Ghidra/Features/Base/.launch/Headless.launch | 2 +- .../ghidra_scripts/SubsToFuncsScript.java | 6 +-- .../app/cmd/refs/SetExternalRefCmd.java | 21 +------- .../merge/datatypes/DataTypeMergeManager.java | 9 ++-- .../merge/listing/AbstractFunctionMerger.java | 6 +-- .../java/ghidra/app/nav/NavigationUtils.java | 6 +-- .../app/plugin/core/analysis/PefAnalyzer.java | 2 +- .../plugin/core/datamgr/DataTypeSyncInfo.java | 8 +-- .../core/datamgr/DataTypeSynchronizer.java | 10 ++-- .../core/datamgr/editor/EnumTableModel.java | 8 +-- .../datawindow/DataWindowFilterDialog.java | 4 +- .../core/disassembler/CallFixupAnalyzer.java | 2 +- .../core/disassembler/EntryPointAnalyzer.java | 2 +- .../ProgramTreeModularizationPlugin.java | 8 +-- .../FunctionReachabilityTableModel.java | 6 +-- .../core/resources/ResourceActionsPlugin.java | 8 +-- .../core/select/flow/SelectByFlowPlugin.java | 11 ++-- .../select/flow/SelectByScopedFlowPlugin.java | 7 ++- .../core/stackeditor/StackFrameDataType.java | 2 +- .../app/services/BlockModelService.java | 8 +-- .../java/ghidra/app/util/CommentTypes.java | 23 ++++---- .../java/ghidra/app/util/XReferenceUtil.java | 6 +-- .../bin/format/golang/rtti/JsonPatch.java | 2 +- .../ghidra/app/util/xml/MarkupXmlMgr.java | 2 +- .../app/util/xml/SymbolTableXmlMgr.java | 2 +- .../java/ghidra/program/util/DiffUtility.java | 4 +- .../BigIntegerNumberInputDialogTest.java | 5 +- .../CodeBrowserClipboardProviderTest.java | 1 + .../core/data/ApplyDataTypeToBrowserTest.java | 5 +- .../FunctionWindowPluginTest.java | 1 + .../ArrayLocationReferencesTest.java | 5 +- .../core/string/StringTableProviderTest.java | 5 +- .../plugintool/dialog/ManagePlugins2Test.java | 5 +- .../plugin/core/checksums/MyTestMemory.java | 5 -- .../replace/AbstractSearchAndReplaceTest.java | 2 +- .../ByteViewerClipboardProviderTest.java | 5 +- .../feature/fid/service/FidProgramSeeker.java | 6 +-- .../developer_scripts/PdbQueryOpenScript.java | 8 +-- .../format/pdb2/pdbreader/SymbolRecords.java | 2 +- .../PDB/src/main/java/pdb/PdbPlugin.java | 26 ++++----- .../VTAbstractReferenceProgramCorrelator.java | 6 +-- .../vt/api/markuptype/CommentMarkupType.java | 4 +- .../vt/api/BSimSelfSimilarCorrelatorTest.java | 10 ++-- .../asm/wild/WildSleighAssemblerTest.java | 1 + .../filter/MatchesPatternTextFilter.java | 4 +- .../DefaultThreadedTableFilterTest.java | 1 + .../textfield/HexOrDecimalInputTest.java | 9 ++-- .../threaded/AbstractThreadedTableTest.java | 1 + .../test/ConcurrentTestExceptionHandler.java | 8 +-- .../framework/LoggingInitialization.java | 9 ++-- .../main/java/ghidra/net/http/HttpUtil.java | 9 ++-- .../main/java/ghidra/util/JavaSourceFile.java | 7 +-- .../java/ghidra/util/StringUtilities.java | 9 ++-- .../java/ghidra/util/xml/XmlUtilities.java | 4 +- .../java/ghidra/net/http/HttpUtilTest.java | 10 ++-- .../test/java/util/CollectionUtilsTest.java | 1 + .../utilities/util/FileUtilitiesTest.java | 5 +- .../reflection/ReflectionUtilitiesTest.java | 5 +- .../graph/job/FilterVerticesJobTest.java | 12 ++--- .../ghidra/graph/GraphAlgorithmsTest.java | 1 + .../main/java/resources/ResourceManager.java | 8 +-- .../src/main/java/help/CustomTOCView.java | 11 ++-- .../Help/src/main/java/help/GHelpSet.java | 7 ++- .../main/java/ghidra/framework/ToolUtils.java | 4 +- .../framework/model/TestDummyDomainFile.java | 4 +- .../model/TestDummyDomainFolder.java | 4 +- .../processors/sleigh/SleighLanguage.java | 2 +- .../java/ghidra/app/util/PseudoCodeUnit.java | 2 - .../program/database/DBStringMapAdapter.java | 8 +-- .../program/database/mem/FileBytes.java | 4 +- .../program/database/mem/MemoryMapDB.java | 5 -- .../sourcemap/UserDataPathTransformer.java | 3 +- .../program/model/listing/Function.java | 2 +- .../program/model/listing/VariableImpl.java | 10 ++-- .../java/ghidra/program/model/mem/Memory.java | 9 ---- .../ghidra/program/model/mem/StubMemory.java | 5 -- .../program/util/SimpleDiffUtility.java | 2 +- .../agent/lldb/rmi/LldbConnectorsTest.java | 14 ++--- .../ShowInstructionInfoPluginScreenShots.java | 5 +- .../app/util/headless/MyHeadlessToolkit.java | 2 +- .../formatter/HexIntegerFormatterTest.java | 5 +- 96 files changed, 311 insertions(+), 334 deletions(-) diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerStaticMappingProviderTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerStaticMappingProviderTest.java index 54178b4031..f8b81edc4a 100644 --- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerStaticMappingProviderTest.java +++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerStaticMappingProviderTest.java @@ -18,7 +18,7 @@ package ghidra.app.plugin.core.debug.gui.modules; import static org.junit.Assert.*; import java.io.IOException; -import java.net.URL; +import java.net.URI; import java.util.*; import org.junit.Before; @@ -64,9 +64,9 @@ public class DebuggerStaticMappingProviderTest extends AbstractGhidraHeadedDebug traceManager.openTrace(tb.trace); traceManager.activateTrace(tb.trace); - try (Transaction tx = tb.startTransaction()) { + try (Transaction _ = tb.startTransaction()) { manager.add(tb.range(0xdeadbeef, 0xdeadbeef + 0xff), Lifespan.nowOn(0), - new URL("ghidra://static"), "DEADBEEF"); + new URI("ghidra://static").toURL(), "DEADBEEF"); } waitForDomainObject(tb.trace); @@ -74,7 +74,7 @@ public class DebuggerStaticMappingProviderTest extends AbstractGhidraHeadedDebug assertEquals(1, displayed.size()); StaticMappingRow record = displayed.get(0); assertEquals(tb.addr(0xdeadbeef), record.getTraceAddress()); - assertEquals(new URL("ghidra://static"), record.getStaticProgramURL()); + assertEquals(new URI("ghidra://static").toURL(), record.getStaticProgramURL()); assertEquals("DEADBEEF", record.getStaticAddress()); assertEquals(0x100, record.getLength()); } @@ -84,9 +84,9 @@ public class DebuggerStaticMappingProviderTest extends AbstractGhidraHeadedDebug traceManager.openTrace(tb.trace); // Note: don't activate yet - try (Transaction tx = tb.startTransaction()) { + try (Transaction _ = tb.startTransaction()) { manager.add(tb.range(0xdeadbeef, 0xdeadbeef + 0xff), Lifespan.nowOn(0), - new URL("ghidra://static"), "DEADBEEF"); + new URI("ghidra://static").toURL(), "DEADBEEF"); } waitForDomainObject(tb.trace); @@ -101,7 +101,7 @@ public class DebuggerStaticMappingProviderTest extends AbstractGhidraHeadedDebug assertEquals(1, displayed.size()); StaticMappingRow record = displayed.get(0); assertEquals(tb.addr(0xdeadbeef), record.getTraceAddress()); - assertEquals(new URL("ghidra://static"), record.getStaticProgramURL()); + assertEquals(new URI("ghidra://static").toURL(), record.getStaticProgramURL()); assertEquals("DEADBEEF", record.getStaticAddress()); assertEquals(0x100, record.getLength()); } @@ -114,7 +114,7 @@ public class DebuggerStaticMappingProviderTest extends AbstractGhidraHeadedDebug intoProject(tb.trace); intoProject(program); - try (Transaction tx = tb.startTransaction()) { + try (Transaction _ = tb.startTransaction()) { tb.createRootObject("Target"); tb.trace.getMemoryManager() .addRegion("Memory[.text]", Lifespan.nowOn(0), @@ -123,7 +123,7 @@ public class DebuggerStaticMappingProviderTest extends AbstractGhidraHeadedDebug } waitForDomainObject(tb.trace); - try (Transaction tx = program.openTransaction("Add block")) { + try (Transaction _ = program.openTransaction("Add block")) { program.getMemory() .createInitializedBlock(".text", addr(program, 0xc0de1234L), 0x100, (byte) 0, TaskMonitor.DUMMY, false); @@ -163,13 +163,13 @@ public class DebuggerStaticMappingProviderTest extends AbstractGhidraHeadedDebug traceManager.openTrace(tb.trace); traceManager.activateTrace(tb.trace); - try (Transaction tx = tb.startTransaction()) { + try (Transaction _ = tb.startTransaction()) { manager.add(tb.range(0xdeadbeef, 0xdeadbeef + 0xff), Lifespan.nowOn(0), - new URL("ghidra://static"), "DEADBEEF"); + new URI("ghidra://static").toURL(), "DEADBEEF"); manager.add(tb.range(0xdeadbeef + 0x100, 0xdeadbeef + 0x17f), Lifespan.nowOn(0), - new URL("ghidra://static"), "C0DE1234"); + new URI("ghidra://static").toURL(), "C0DE1234"); manager.add(tb.range(0xdeadbeef + 0x180, 0xdeadbeef + 0x1bf), Lifespan.nowOn(0), - new URL("ghidra://static"), "1E55C0DE"); + new URI("ghidra://static").toURL(), "1E55C0DE"); } waitForDomainObject(tb.trace); @@ -204,13 +204,13 @@ public class DebuggerStaticMappingProviderTest extends AbstractGhidraHeadedDebug traceManager.openTrace(tb.trace); traceManager.activateTrace(tb.trace); - try (Transaction tx = tb.startTransaction()) { + try (Transaction _ = tb.startTransaction()) { manager.add(tb.range(0xdeadbeef, 0xdeadbeef + 0xff), Lifespan.nowOn(0), - new URL("ghidra://static"), "DEADBEEF"); + new URI("ghidra://static").toURL(), "DEADBEEF"); manager.add(tb.range(0xdeadbeef + 0x100, 0xdeadbeef + 0x17f), Lifespan.nowOn(0), - new URL("ghidra://static"), "C0DE1234"); + new URI("ghidra://static").toURL(), "C0DE1234"); manager.add(tb.range(0xdeadbeef + 0x180, 0xdeadbeef + 0x1bf), Lifespan.nowOn(0), - new URL("ghidra://static"), "1E55C0DE"); + new URI("ghidra://static").toURL(), "1E55C0DE"); } waitForDomainObject(tb.trace); @@ -219,7 +219,7 @@ public class DebuggerStaticMappingProviderTest extends AbstractGhidraHeadedDebug assertEquals(3, displayed.size()); // Remove the first two in another transaction - try (Transaction tx = tb.startTransaction()) { + try (Transaction _ = tb.startTransaction()) { manager.findContaining(tb.addr(0xdeadbeef), 0).delete(); manager.findContaining(tb.addr(0xdeadbeef + 0x100), 0).delete(); } @@ -237,16 +237,16 @@ public class DebuggerStaticMappingProviderTest extends AbstractGhidraHeadedDebug traceManager.openTrace(tb.trace); traceManager.activateTrace(tb.trace); - try (Transaction tx = tb.startTransaction()) { + try (Transaction _ = tb.startTransaction()) { manager.add(tb.range(0xdeadbeef, 0xdeadbeef + 0xff), Lifespan.nowOn(0), - new URL("ghidra://static"), "DEADBEEF"); + new URI("ghidra://static").toURL(), "DEADBEEF"); manager.add(tb.range(0xdeadbeef + 0x100, 0xdeadbeef + 0x17f), Lifespan.nowOn(0), - new URL("ghidra://static"), "C0DE1234"); + new URI("ghidra://static").toURL(), "C0DE1234"); } - try (Transaction tx = tb.startTransaction()) { + try (Transaction _ = tb.startTransaction()) { manager.add(tb.range(0xdeadbeef + 0x180, 0xdeadbeef + 0x1bf), Lifespan.nowOn(0), - new URL("ghidra://static"), "1E55C0DE"); + new URI("ghidra://static").toURL(), "1E55C0DE"); } waitForDomainObject(tb.trace); @@ -264,16 +264,16 @@ public class DebuggerStaticMappingProviderTest extends AbstractGhidraHeadedDebug traceManager.openTrace(tb.trace); traceManager.activateTrace(tb.trace); - try (Transaction tx = tb.startTransaction()) { + try (Transaction _ = tb.startTransaction()) { manager.add(tb.range(0xdeadbeef, 0xdeadbeef + 0xff), Lifespan.nowOn(0), - new URL("ghidra://static"), "DEADBEEF"); + new URI("ghidra://static").toURL(), "DEADBEEF"); manager.add(tb.range(0xdeadbeef + 0x100, 0xdeadbeef + 0x17f), Lifespan.nowOn(0), - new URL("ghidra://static"), "C0DE1234"); + new URI("ghidra://static").toURL(), "C0DE1234"); } try (Transaction tx = tb.startTransaction()) { manager.add(tb.range(0xdeadbeef + 0x180, 0xdeadbeef + 0x1bf), Lifespan.nowOn(0), - new URL("ghidra://static"), "1E55C0DE"); + new URI("ghidra://static").toURL(), "1E55C0DE"); waitForDomainObject(tb.trace); // Check that all records are displayed in the interim diff --git a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/guest/DBTraceGuestPlatformMappedMemory.java b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/guest/DBTraceGuestPlatformMappedMemory.java index ea70425ed2..093d915408 100644 --- a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/guest/DBTraceGuestPlatformMappedMemory.java +++ b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/guest/DBTraceGuestPlatformMappedMemory.java @@ -15,7 +15,7 @@ */ package ghidra.trace.database.guest; -import static ghidra.lifecycle.Unfinished.TODO; +import static ghidra.lifecycle.Unfinished.*; import java.io.IOException; import java.io.InputStream; @@ -209,11 +209,6 @@ public class DBTraceGuestPlatformMappedMemory implements Memory { return TODO(); } - @Override - public AddressSetView getInitializedAddressSet() { - return TODO(); - } - @Override public AddressSetView getExecuteSet() { return TODO(); diff --git a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/program/AbstractDBTraceProgramViewMemory.java b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/program/AbstractDBTraceProgramViewMemory.java index cb25bf57d3..845a538a23 100644 --- a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/program/AbstractDBTraceProgramViewMemory.java +++ b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/program/AbstractDBTraceProgramViewMemory.java @@ -124,11 +124,6 @@ public abstract class AbstractDBTraceProgramViewMemory return getOrComputeAddressSet(); } - @Override - public AddressSetView getInitializedAddressSet() { - return getOrComputeAddressSet(); - } - @Override public boolean isBigEndian() { return program.getLanguage().isBigEndian(); diff --git a/Ghidra/Debug/ProposedUtils/src/main/java/ghidra/util/datastruct/PrivatelyQueuedListener.java b/Ghidra/Debug/ProposedUtils/src/main/java/ghidra/util/datastruct/PrivatelyQueuedListener.java index 843022d9ae..11345c975a 100644 --- a/Ghidra/Debug/ProposedUtils/src/main/java/ghidra/util/datastruct/PrivatelyQueuedListener.java +++ b/Ghidra/Debug/ProposedUtils/src/main/java/ghidra/util/datastruct/PrivatelyQueuedListener.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -110,7 +110,7 @@ public class PrivatelyQueuedListener

{ */ public PrivatelyQueuedListener(Class

iface, String threadNamePattern, P out) { this(iface, Executors.newSingleThreadExecutor( - new BasicThreadFactory.Builder().namingPattern(threadNamePattern).build()), out); + BasicThreadFactory.builder().namingPattern(threadNamePattern).build()), out); } public void setErrorHandler(ListenerErrorHandler errorHandler) { diff --git a/Ghidra/Extensions/sample/src/main/java/ghidra/examples/graph/SampleGraphProvider.java b/Ghidra/Extensions/sample/src/main/java/ghidra/examples/graph/SampleGraphProvider.java index 5ba8c43ca1..df69e79ff3 100644 --- a/Ghidra/Extensions/sample/src/main/java/ghidra/examples/graph/SampleGraphProvider.java +++ b/Ghidra/Extensions/sample/src/main/java/ghidra/examples/graph/SampleGraphProvider.java @@ -26,7 +26,7 @@ import javax.swing.*; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; -import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Strings; import docking.ActionContext; import docking.ComponentProvider; @@ -165,7 +165,7 @@ public class SampleGraphProvider extends ComponentProviderAdapter { GraphViewer viewer = view.getPrimaryGraphViewer(); Predicate filter = - v -> StringUtils.containsIgnoreCase(v.getName(), filterText); + v -> Strings.CI.contains(v.getName(), filterText); FilterVerticesJob job = new FilterVerticesJob<>(viewer, graph, filter, remove); diff --git a/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimClientFactory.java b/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimClientFactory.java index a029d2864d..1e8da88e4c 100755 --- a/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimClientFactory.java +++ b/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimClientFactory.java @@ -15,8 +15,7 @@ */ package ghidra.features.bsim.query; -import java.net.MalformedURLException; -import java.net.URL; +import java.net.*; import ghidra.features.bsim.query.client.PostgresFunctionDatabase; import ghidra.features.bsim.query.elastic.ElasticDatabase; @@ -34,9 +33,10 @@ public class BSimClientFactory { * @param urlString the URL to build * @return the parsed URL object * @throws MalformedURLException if the URL string cannot be parsed + * @throws URISyntaxException if the URL string cannot be parsed */ - public static URL buildURL(String urlString) throws MalformedURLException { - URL url = new URL(urlString); + public static URL buildURL(String urlString) throws MalformedURLException, URISyntaxException { + URL url = new URI(urlString).toURL(); checkBSimServerURL(url); return url; } @@ -73,11 +73,12 @@ public class BSimClientFactory { * @param urlString is the "related" URL * @return the root BSim URL * @throws MalformedURLException if the given URL string cannot be parsed + * @throws URISyntaxException if the given URL string cannot be parsed * @throws IllegalArgumentException if local ghidra URL is specified */ public static URL deriveBSimURL(String urlString) - throws IllegalArgumentException, MalformedURLException { - URL url = new URL(urlString); // URL used only for parsing purposes + throws IllegalArgumentException, MalformedURLException, URISyntaxException { + URL url = new URI(urlString).toURL(); // URL used only for parsing purposes String protocol = url.getProtocol(); if ("postgresql".equals(protocol) || "https".equals(protocol) || "elastic".equals(protocol) || "file".equals(protocol)) { @@ -130,7 +131,7 @@ public class BSimClientFactory { try { return buildClient(bsimServerInfo.toURL(), async); } - catch (MalformedURLException e) { + catch (MalformedURLException | URISyntaxException e) { throw new RuntimeException(e); // unexpected } } diff --git a/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimPostgresDBConnectionManager.java b/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimPostgresDBConnectionManager.java index c0f75aeb9a..cb728a37db 100644 --- a/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimPostgresDBConnectionManager.java +++ b/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimPostgresDBConnectionManager.java @@ -52,7 +52,7 @@ public class BSimPostgresDBConnectionManager { info -> new BSimPostgresDataSource(info)); } - @Deprecated + @Deprecated(since = "11.0", forRemoval = true) public static BSimPostgresDataSource getDataSource(URL postgresUrl) { return getDataSource(new BSimServerInfo(postgresUrl)); } diff --git a/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimServerInfo.java b/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimServerInfo.java index 6ac7969f29..5d73b65e85 100644 --- a/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimServerInfo.java +++ b/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimServerInfo.java @@ -352,9 +352,10 @@ public class BSimServerInfo implements Comparable { * Warning: If userinfo with password has been specified it will be returned in the URL. * @return BSim server info in URL * @throws MalformedURLException if unable to form supported URL + * @throws URISyntaxException if unable to form supported URL */ - public URL toURL() throws MalformedURLException { - return new URL(toURLString()); + public URL toURL() throws MalformedURLException, URISyntaxException { + return new URI(toURLString()).toURL(); } /** diff --git a/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/FunctionDatabase.java b/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/FunctionDatabase.java index c1bb78cc6c..75004b980d 100755 --- a/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/FunctionDatabase.java +++ b/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/FunctionDatabase.java @@ -178,7 +178,7 @@ public interface FunctionDatabase extends AutoCloseable { */ public BSimServerInfo getServerInfo(); - @Deprecated + @Deprecated(since = "11.0") public String getURLString(); /** diff --git a/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/PostgresFunctionDatabase.java b/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/PostgresFunctionDatabase.java index cb529d6f18..2a4e4b2686 100755 --- a/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/PostgresFunctionDatabase.java +++ b/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/PostgresFunctionDatabase.java @@ -74,7 +74,7 @@ public final class PostgresFunctionDatabase new CachedStatement<>(); public PostgresFunctionDatabase(URL postgresUrl, boolean async) { - super(BSimPostgresDBConnectionManager.getDataSource(postgresUrl), + super(BSimPostgresDBConnectionManager.getDataSource(new BSimServerInfo(postgresUrl)), FunctionDatabase.generateLSHVectorFactory(), LAYOUT_VERSION); postgresDs = (BSimPostgresDataSource) ds; asynchronous = async; diff --git a/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticConnection.java b/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticConnection.java index ff6feac8f0..0d0acabbb5 100755 --- a/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticConnection.java +++ b/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticConnection.java @@ -16,8 +16,7 @@ package ghidra.features.bsim.query.elastic; import java.io.*; -import java.net.HttpURLConnection; -import java.net.URL; +import java.net.*; import com.google.gson.*; @@ -188,7 +187,7 @@ public class ElasticConnection { throws ElasticException { HttpURLConnection connection = null; try { - URL httpURL = new URL(hostURL + path); + URL httpURL = new URI(hostURL + path).toURL(); connection = (HttpURLConnection) httpURL.openConnection(); connection.setRequestMethod(command); connection.setRequestProperty("Content-Type", "application/json"); @@ -203,6 +202,9 @@ public class ElasticConnection { } return resp; } + catch (URISyntaxException e) { + throw new ElasticException("Error parsing URL: " + e.getMessage()); + } catch (IOException e) { throw new ElasticException("Error sending request: " + e.getMessage()); } @@ -228,7 +230,7 @@ public class ElasticConnection { throws ElasticException { HttpURLConnection connection = null; try { - URL httpURL = new URL(httpURLbase + path); + URL httpURL = new URI(httpURLbase + path).toURL(); connection = (HttpURLConnection) httpURL.openConnection(); connection.setRequestMethod(command); connection.setRequestProperty("Content-Type", "application/json"); @@ -242,6 +244,9 @@ public class ElasticConnection { throw new ElasticException(parseErrorJSON(resp)); } } + catch (URISyntaxException e) { + throw new ElasticException("Error parsing URL: " + e.getMessage()); + } catch (IOException e) { throw new ElasticException("Error sending request: " + e.getMessage()); } @@ -267,7 +272,7 @@ public class ElasticConnection { throws ElasticException { HttpURLConnection connection = null; try { - URL httpURL = new URL(httpURLbase + path); + URL httpURL = new URI(httpURLbase + path).toURL(); connection = (HttpURLConnection) httpURL.openConnection(); connection.setRequestMethod(command); connection.setRequestProperty("Content-Type", "application/json"); @@ -282,6 +287,9 @@ public class ElasticConnection { } return resp; } + catch (URISyntaxException e) { + throw new ElasticException("Error parsing URL: " + e.getMessage()); + } catch (IOException e) { throw new ElasticException("Error sending request: " + e.getMessage()); } @@ -308,7 +316,7 @@ public class ElasticConnection { throws ElasticException { HttpURLConnection connection = null; try { - URL httpURL = new URL(httpURLbase + path); + URL httpURL = new URI(httpURLbase + path).toURL(); connection = (HttpURLConnection) httpURL.openConnection(); connection.setRequestMethod(command); connection.setRequestProperty("Content-Type", "application/json"); @@ -320,6 +328,9 @@ public class ElasticConnection { JsonObject resp = grabResponse(connection); return resp; } + catch (URISyntaxException e) { + throw new ElasticException("Error parsing URL: " + e.getMessage()); + } catch (IOException e) { throw new ElasticException("Error sending request: " + e.getMessage()); } @@ -344,7 +355,7 @@ public class ElasticConnection { public JsonObject executeBulk(String path, String body) throws ElasticException { HttpURLConnection connection = null; try { - URL httpURL = new URL(hostURL + path); + URL httpURL = new URI(hostURL + path).toURL(); connection = (HttpURLConnection) httpURL.openConnection(); connection.setRequestMethod(POST); connection.setRequestProperty("Content-Type", "application/x-ndjson"); @@ -359,6 +370,9 @@ public class ElasticConnection { } return resp; } + catch (URISyntaxException e) { + throw new ElasticException("Error parsing URL: " + e.getMessage()); + } catch (IOException e) { throw new ElasticException("Error sending request: " + e.getMessage()); } @@ -375,7 +389,7 @@ public class ElasticConnection { public JsonObject executeURIOnly(String command, String path) throws ElasticException { HttpURLConnection connection = null; try { - URL httpURL = new URL(httpURLbase + path); + URL httpURL = new URI(httpURLbase + path).toURL(); connection = (HttpURLConnection) httpURL.openConnection(); connection.setRequestMethod(command); connection.setDoOutput(true); @@ -386,6 +400,9 @@ public class ElasticConnection { } return resp; } + catch (URISyntaxException e) { + throw new ElasticException("Error parsing URL: " + e.getMessage()); + } catch (IOException e) { throw new ElasticException("Error sending request: " + e.getMessage()); } diff --git a/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/facade/SimilarFunctionQueryService.java b/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/facade/SimilarFunctionQueryService.java index 36c337098a..5f04fe1801 100755 --- a/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/facade/SimilarFunctionQueryService.java +++ b/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/facade/SimilarFunctionQueryService.java @@ -15,8 +15,7 @@ */ package ghidra.features.bsim.query.facade; -import java.net.MalformedURLException; -import java.net.URL; +import java.net.*; import java.util.Set; import generic.lsh.vector.LSHVectorFactory; @@ -415,7 +414,8 @@ public class SimilarFunctionQueryService implements AutoCloseable { } // NOTE: Method overriden for testing - protected FunctionDatabase createDatabase(String urlString) throws MalformedURLException { + protected FunctionDatabase createDatabase(String urlString) + throws MalformedURLException, URISyntaxException { URL url = BSimClientFactory.deriveBSimURL(urlString); return BSimClientFactory.buildClient(url, false); } @@ -435,7 +435,7 @@ public class SimilarFunctionQueryService implements AutoCloseable { try { database = createDatabase(serverURLString); } - catch (MalformedURLException e) { + catch (MalformedURLException | URISyntaxException e) { throw new QueryDatabaseException("Bad database URL: " + e.getMessage()); } boolean success = database.initialize(); diff --git a/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/file/H2FileFunctionDatabase.java b/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/file/H2FileFunctionDatabase.java index 4822068a27..7fd66ebf39 100644 --- a/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/file/H2FileFunctionDatabase.java +++ b/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/file/H2FileFunctionDatabase.java @@ -52,7 +52,7 @@ public class H2FileFunctionDatabase extends AbstractSQLFunctionDatabase - + diff --git a/Ghidra/Features/Base/ghidra_scripts/SubsToFuncsScript.java b/Ghidra/Features/Base/ghidra_scripts/SubsToFuncsScript.java index 9504f8f2d3..fa43ef719a 100644 --- a/Ghidra/Features/Base/ghidra_scripts/SubsToFuncsScript.java +++ b/Ghidra/Features/Base/ghidra_scripts/SubsToFuncsScript.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,7 +34,7 @@ public class SubsToFuncsScript extends GhidraScript { BlockModelService blockModelService = state.getTool().getService(BlockModelService.class); Listing listing = currentProgram.getListing(); StringBuffer errorBuf = new StringBuffer(); - CodeBlockModel cbm = blockModelService.getActiveSubroutineModel(); + CodeBlockModel cbm = blockModelService.getActiveSubroutineModel(currentProgram); AddressSetView addrset = currentSelection == null ? (AddressSetView) currentProgram.getMemory() : currentSelection; diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/refs/SetExternalRefCmd.java b/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/refs/SetExternalRefCmd.java index 5aa057cd93..b09049feb6 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/refs/SetExternalRefCmd.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/cmd/refs/SetExternalRefCmd.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -57,23 +57,6 @@ public class SetExternalRefCmd implements Command { this.source = source; } - /** - * Constructs a new command for adding an external reference from data using {@link RefType#DATA}. - * @param fromAddr from address (source of the reference) - * @param opIndex operand index - * @param extName name of external program - * @param extLabel label within the external program, may be null if extAddr is not null - * @param extAddr address within the external program, may be null - * @param source the source of this reference - * @deprecated the other constructor form should be used with an appropriate RefType specified. - * {@link RefType#DATA} should be used for address table pointer references. - */ - @Deprecated - public SetExternalRefCmd(Address fromAddr, int opIndex, String extName, String extLabel, - Address extAddr, SourceType source) { - this(fromAddr, opIndex, extName, extLabel, extAddr, RefType.DATA, source); - } - /** * * @see ghidra.framework.cmd.Command#applyTo(ghidra.framework.model.DomainObject) diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/merge/datatypes/DataTypeMergeManager.java b/Ghidra/Features/Base/src/main/java/ghidra/app/merge/datatypes/DataTypeMergeManager.java index 0c3c1bf157..05d6ca7113 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/merge/datatypes/DataTypeMergeManager.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/merge/datatypes/DataTypeMergeManager.java @@ -21,6 +21,7 @@ import java.util.*; import javax.swing.SwingUtilities; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Strings; import ghidra.app.merge.*; import ghidra.app.util.HelpTopics; @@ -3075,9 +3076,9 @@ public class DataTypeMergeManager implements MergeResolver { String latestName = latestSourceArchive.getName(); String myName = mySourceArchive.getName(); - boolean sameName = StringUtils.equals(myName, latestName); - boolean latestChangedName = !StringUtils.equals(origName, latestName); - boolean myChangedName = !StringUtils.equals(origName, myName); + boolean sameName = Strings.CS.equals(myName, latestName); + boolean latestChangedName = !Strings.CS.equals(origName, latestName); + boolean myChangedName = !Strings.CS.equals(origName, myName); // Neither removed the source archive so see what changed. if (!sameName && latestChangedName && myChangedName) { archiveConflictList.add(myChangeIDObject); @@ -3104,7 +3105,7 @@ public class DataTypeMergeManager implements MergeResolver { if (myAddID == latestAddID) { SourceArchive latestSourceArchive = dtms[LATEST].getSourceArchive(new UniversalID(latestAddID)); - if (!StringUtils.equals(mySourceArchive.getName(), + if (!Strings.CS.equals(mySourceArchive.getName(), latestSourceArchive.getName())) { archiveConflictList.add(Long.valueOf(myAddID)); foundConflict = true; diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/merge/listing/AbstractFunctionMerger.java b/Ghidra/Features/Base/src/main/java/ghidra/app/merge/listing/AbstractFunctionMerger.java index bfd673c919..83e845f095 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/merge/listing/AbstractFunctionMerger.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/merge/listing/AbstractFunctionMerger.java @@ -23,7 +23,7 @@ import javax.swing.SwingUtilities; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Strings; import docking.widgets.dialogs.ReadTextDialog; import generic.stl.Pair; @@ -750,10 +750,10 @@ abstract class AbstractFunctionMerger implements ListingMergeConstants { if (!f1Parms[i].isEquivalent(f2Parms[i])) { return false; } - if (!StringUtils.equals(f1Parms[i].getName(), f2Parms[i].getName())) { + if (!Strings.CS.equals(f1Parms[i].getName(), f2Parms[i].getName())) { return false; } - if (!StringUtils.equals(f1Parms[i].getComment(), f2Parms[i].getComment())) { + if (!Strings.CS.equals(f1Parms[i].getComment(), f2Parms[i].getComment())) { return false; } } diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/nav/NavigationUtils.java b/Ghidra/Features/Base/src/main/java/ghidra/app/nav/NavigationUtils.java index 53ba992313..d1b5dc571b 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/nav/NavigationUtils.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/nav/NavigationUtils.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -112,7 +112,7 @@ public class NavigationUtils { return; } Function extFunc = (Function) s.getObject(); - Address[] thunkAddrs = extFunc.getFunctionThunkAddresses(); + Address[] thunkAddrs = extFunc.getFunctionThunkAddresses(false); if (thunkAddrs == null) { return; } diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/PefAnalyzer.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/PefAnalyzer.java index 125e13fd2a..3e62f13094 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/PefAnalyzer.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/PefAnalyzer.java @@ -56,7 +56,7 @@ public class PefAnalyzer extends AbstractAnalyzer { Listing listing = program.getListing(); ReferenceManager referenceManager = program.getReferenceManager(); Symbol tocSymbol = SymbolUtilities.getExpectedLabelOrFunctionSymbol(program, - PefConstants.TOC, err -> log.error(getName(), err)); + PefConstants.TOC, err -> log.appendMsg(getName() + ": " + err)); if (tocSymbol == null) { return true; } diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypeSyncInfo.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypeSyncInfo.java index a26ce6516d..d56e6c8697 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypeSyncInfo.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypeSyncInfo.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,7 @@ package ghidra.app.plugin.core.datamgr; import java.util.Date; -import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Strings; import ghidra.program.model.data.DataType; import ghidra.program.model.data.DataTypeManager; @@ -194,7 +194,7 @@ public class DataTypeSyncInfo { if (!DataTypeSynchronizer.namesAreEquivalent(sourceDt, refDt)) { return true; } - if (!StringUtils.equals(refDt.getDescription(), sourceDt.getDescription())) { + if (!Strings.CS.equals(refDt.getDescription(), sourceDt.getDescription())) { return true; } } diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypeSynchronizer.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypeSynchronizer.java index c2c6f8cd69..f74ebdc108 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypeSynchronizer.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypeSynchronizer.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,7 +22,7 @@ import java.util.function.Consumer; import javax.swing.JLabel; import javax.swing.SwingUtilities; -import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Strings; import docking.widgets.label.GDHtmlLabel; import ghidra.app.plugin.core.datamgr.archive.DataTypeManagerHandler; @@ -124,7 +124,7 @@ public class DataTypeSynchronizer { if (!namesAreEquivalent(refDT, sourceDT)) { renameDataType(sourceDTM, sourceDT, refDT); } - if (!StringUtils.equals(refDT.getDescription(), sourceDT.getDescription())) { + if (!Strings.CS.equals(refDT.getDescription(), sourceDT.getDescription())) { sourceDT.setDescription(refDT.getDescription()); } } @@ -139,7 +139,7 @@ public class DataTypeSynchronizer { if (!namesAreEquivalent(refDT, sourceDT)) { renameDataType(refDTM, refDT, sourceDT); } - if (!StringUtils.equals(sourceDT.getDescription(), refDT.getDescription())) { + if (!Strings.CS.equals(sourceDT.getDescription(), refDT.getDescription())) { refDT.setDescription(sourceDT.getDescription()); } } diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/editor/EnumTableModel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/editor/EnumTableModel.java index 1ab36e88cb..e0f90e0358 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/editor/EnumTableModel.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/editor/EnumTableModel.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,7 @@ package ghidra.app.plugin.core.datamgr.editor; import java.util.*; -import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Strings; import docking.widgets.table.AbstractSortedTableModel; import docking.widgets.table.TableSortState; @@ -355,7 +355,7 @@ class EnumTableModel extends AbstractSortedTableModel { private class EnumCommentComparator implements Comparator { @Override public int compare(EnumEntry entry1, EnumEntry entry2) { - return StringUtils.compare(entry1.getComment(), entry2.getComment()); + return Strings.CS.compare(entry1.getComment(), entry2.getComment()); } } } diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datawindow/DataWindowFilterDialog.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datawindow/DataWindowFilterDialog.java index 8693fb4f5e..3ac94a5833 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datawindow/DataWindowFilterDialog.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datawindow/DataWindowFilterDialog.java @@ -234,7 +234,7 @@ class DataWindowFilterDialog extends DialogComponentProvider { Set> entrySet = typeEnabledMap.entrySet(); for (Entry entry : entrySet) { String checkboxName = entry.getKey(); - if (StringUtils.containsIgnoreCase(checkboxName, filterText)) { + if (Strings.CI.contains(checkboxName, filterText)) { checkboxNameList.add(checkboxName); } } @@ -254,7 +254,7 @@ class DataWindowFilterDialog extends DialogComponentProvider { plugin.setFilterEnabled(false); } else { - Coverage coverage = (Coverage) coverageCombo.getSelectedItem(); + Coverage coverage = coverageCombo.getSelectedItem(); plugin.setFilter(typeEnabledMap, coverage); } diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/CallFixupAnalyzer.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/CallFixupAnalyzer.java index 8dd9fbdb8e..3b19bb8f43 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/CallFixupAnalyzer.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/CallFixupAnalyzer.java @@ -176,7 +176,7 @@ public class CallFixupAnalyzer extends AbstractAnalyzer { private void addInThunkedFunctionsToList(Program program, AddressSetView initialSet, Function function, AddressSet functionAddresses) { - Address[] thunkAddrs = function.getFunctionThunkAddresses(); + Address[] thunkAddrs = function.getFunctionThunkAddresses(false); if (thunkAddrs != null) { for (Address addr : thunkAddrs) { if (!initialSet.contains(addr)) { diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/EntryPointAnalyzer.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/EntryPointAnalyzer.java index faec72c46b..fccbe84076 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/EntryPointAnalyzer.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/EntryPointAnalyzer.java @@ -217,7 +217,7 @@ public class EntryPointAnalyzer extends AbstractAnalyzer { } if (!foundNonJumpRef) { // check if we have been thunked - Address[] functionThunkAddresses = function.getFunctionThunkAddresses(); + Address[] functionThunkAddresses = function.getFunctionThunkAddresses(false); foundNonJumpRef = functionThunkAddresses != null && functionThunkAddresses.length != 0; } diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/programtree/ProgramTreeModularizationPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/programtree/ProgramTreeModularizationPlugin.java index e3ac1909f0..f489de8ecc 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/programtree/ProgramTreeModularizationPlugin.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/programtree/ProgramTreeModularizationPlugin.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -124,7 +124,7 @@ public class ProgramTreeModularizationPlugin extends ProgramPlugin { DominanceModularizationCmd cmd = new DominanceModularizationCmd(node.getGroupPath(), node.getGroup().getTreeName(), - currentSelection, blockModelService.getActiveSubroutineModel()); + currentSelection, blockModelService.getActiveSubroutineModel(currentProgram)); tool.executeBackgroundCommand(cmd, currentProgram); } @@ -137,7 +137,7 @@ public class ProgramTreeModularizationPlugin extends ProgramPlugin { ComplexityDepthModularizationCmd cmd = new ComplexityDepthModularizationCmd(node.getGroupPath(), node.getGroup().getTreeName(), currentSelection, - blockModelService.getActiveSubroutineModel()); + blockModelService.getActiveSubroutineModel(currentProgram)); tool.executeBackgroundCommand(cmd, currentProgram); } diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/reachability/FunctionReachabilityTableModel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/reachability/FunctionReachabilityTableModel.java index f467d985bd..c2fd1d6bc2 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/reachability/FunctionReachabilityTableModel.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/reachability/FunctionReachabilityTableModel.java @@ -136,12 +136,12 @@ public class FunctionReachabilityTableModel CodeBlockModel model; try { model = blockModelService.getNewModelByName( - BlockModelService.ISOLATED_ENTRY_SUBROUTINE_MODEL_NAME); + BlockModelService.ISOLATED_ENTRY_SUBROUTINE_MODEL_NAME, program); } catch (NotFoundException e) { Msg.error(this, "Code block model not found: " + BlockModelService.ISOLATED_ENTRY_SUBROUTINE_MODEL_NAME); - model = blockModelService.getActiveSubroutineModel(); + model = blockModelService.getActiveSubroutineModel(program); } return model.getCodeBlocks(monitor); @@ -179,7 +179,7 @@ public class FunctionReachabilityTableModel Address targetAddress = destination.getDestinationAddress(); BlockModelService blockModelService = serviceProvider.getService(BlockModelService.class); - CodeBlockModel codeBlockModel = blockModelService.getActiveSubroutineModel(); + CodeBlockModel codeBlockModel = blockModelService.getActiveSubroutineModel(program); CodeBlock targetBlock = codeBlockModel.getFirstCodeBlockContaining(targetAddress, monitor); if (targetBlock == null) { return null; // no code found for call; external? diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/resources/ResourceActionsPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/resources/ResourceActionsPlugin.java index b956d386ce..9b01763c59 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/resources/ResourceActionsPlugin.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/resources/ResourceActionsPlugin.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -69,7 +69,7 @@ public class ResourceActionsPlugin extends Plugin { new ActionBuilder("Save Image New Format", getName()) .withContext(ProgramLocationActionContext.class) - .validContextWhen(plac -> plac.getLocation() instanceof ResourceFieldLocation && + .validWhen(plac -> plac.getLocation() instanceof ResourceFieldLocation && ((ResourceFieldLocation) plac.getLocation()).isDataImageResource()) .onAction( plac -> saveImageAsNewImage((ResourceFieldLocation) plac.getLocation())) @@ -78,7 +78,7 @@ public class ResourceActionsPlugin extends Plugin { new ActionBuilder("Save Image Original Bytes", getName()) .withContext(ProgramLocationActionContext.class) - .validContextWhen(plac -> plac.getLocation() instanceof ResourceFieldLocation && + .validWhen(plac -> plac.getLocation() instanceof ResourceFieldLocation && ((ResourceFieldLocation) plac.getLocation()).isDataImageResource()) .onAction( plac -> saveImageOriginalBytes((ResourceFieldLocation) plac.getLocation())) diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/select/flow/SelectByFlowPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/select/flow/SelectByFlowPlugin.java index bf9317bfe0..eb9f4392bf 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/select/flow/SelectByFlowPlugin.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/select/flow/SelectByFlowPlugin.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -40,7 +40,8 @@ import ghidra.program.util.ProgramSelection; import ghidra.util.HelpLocation; import ghidra.util.exception.CancelledException; import ghidra.util.exception.InvalidInputException; -import ghidra.util.task.*; +import ghidra.util.task.Task; +import ghidra.util.task.TaskMonitor; /** * The SelectByFlowPlugin adds selection of code based on program flow to a @@ -347,7 +348,7 @@ public class SelectByFlowPlugin extends Plugin implements OptionsChangeListener monitor.initialize(startAddresses.getNumAddresses()); - CodeBlockModel cbm = blockModelService.getActiveSubroutineModel(); + CodeBlockModel cbm = blockModelService.getActiveSubroutineModel(program); CodeBlockIterator iter = cbm.getCodeBlocksContaining(startAddresses, monitor); while (iter.hasNext()) { if (monitor.isCancelled()) { @@ -382,7 +383,7 @@ public class SelectByFlowPlugin extends Plugin implements OptionsChangeListener monitor.initialize(startAddresses.getNumAddresses()); ReferenceManager rm = program.getReferenceManager(); - CodeBlockModel cbm = blockModelService.getActiveSubroutineModel(); + CodeBlockModel cbm = blockModelService.getActiveSubroutineModel(program); CodeBlockIterator cbIter = cbm.getCodeBlocksContaining(startAddresses, monitor); while (cbIter.hasNext()) { diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/select/flow/SelectByScopedFlowPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/select/flow/SelectByScopedFlowPlugin.java index 914f776bbb..fbde46a2fd 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/select/flow/SelectByScopedFlowPlugin.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/select/flow/SelectByScopedFlowPlugin.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -238,8 +238,7 @@ public class SelectByScopedFlowPlugin extends ProgramPlugin { private ProgramSelection makeSelectionFromCodeBlocks(Collection blocks, Program program) { AddressSet set = getAddressForCodeBlocks(blocks, program); - AddressFactory addressFactory = program.getAddressFactory(); - ProgramSelection selection = new ProgramSelection(addressFactory, set); + ProgramSelection selection = new ProgramSelection(set); return selection; } diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/stackeditor/StackFrameDataType.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/stackeditor/StackFrameDataType.java index 8769211e4d..4e2746bbde 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/stackeditor/StackFrameDataType.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/stackeditor/StackFrameDataType.java @@ -1131,7 +1131,7 @@ class StackFrameDataType implements Structure { wrappedStruct.delete(ordinal); - Range r = Range.between(stackOffset, stackOffset + len - 1); + Range r = Range.of(stackOffset, stackOffset + len - 1); if (r.contains(parameterOffset)) { int negLenReduction = parameterOffset - stackOffset; negativeLength -= negLenReduction; diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/services/BlockModelService.java b/Ghidra/Features/Base/src/main/java/ghidra/app/services/BlockModelService.java index 4b58cd47f9..9b3f7927ee 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/services/BlockModelService.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/services/BlockModelService.java @@ -131,7 +131,7 @@ public interface BlockModelService { /** * Get new instance of the active Subroutine Block model for the current program. * @return new Subroutine Block model instance or null if program is not open - * @deprecated use getActiveSubroutineModel(Program) instead + * @deprecated use {@link #getActiveSubroutineModel(Program)} instead */ @Deprecated(since = "9.0") public CodeBlockModel getActiveSubroutineModel(); @@ -140,7 +140,7 @@ public interface BlockModelService { * Get new instance of the active Subroutine Block model for the current program. * @param includeExternals externals are included if true * @return new Subroutine Block model instance or null if program is not open - * @deprecated use getActiveSubroutineModel(Program) instead + * @deprecated use {@link #getActiveSubroutineModel(Program, boolean)} instead */ @Deprecated(since = "9.0") public CodeBlockModel getActiveSubroutineModel(boolean includeExternals); @@ -171,7 +171,7 @@ public interface BlockModelService { * @param modelName name of registered block model * @return new model instance or null if program is not open. * @throws NotFoundException if specified model is not registered - * @deprecated use getNewModelByName(String, Program) instead + * @deprecated use {@link #getNewModelByName(String, Program)} instead */ @Deprecated public CodeBlockModel getNewModelByName(String modelName) @@ -183,7 +183,7 @@ public interface BlockModelService { * @param includeExternals externals are included if true * @return new model instance or null if program is not open. * @throws NotFoundException if specified model is not registered - * @deprecated use getNewModelByName(String, Program, boolean) instead + * @deprecated use {@link #getNewModelByName(String, Program, boolean)} instead */ @Deprecated public CodeBlockModel getNewModelByName(String modelName, boolean includeExternals) diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/CommentTypes.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/CommentTypes.java index 1394560176..0817cef64f 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/CommentTypes.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/CommentTypes.java @@ -15,37 +15,32 @@ */ package ghidra.app.util; -import ghidra.program.model.listing.CodeUnit; import ghidra.program.model.listing.CommentType; /** * Class with a convenience method to get an array of the CodeUnit * comment types. The method is useful to loop through the comment types * once you have a code unit. + * * @deprecated the {@link CommentType enum should be used in place of integers} */ @Deprecated(forRemoval = true, since = "11.4") public class CommentTypes { - private static int[] COMMENT_TYPES; - private static int NUMBER_OF_COMMENT_TYPES = 5; - + @Deprecated(forRemoval = true, since = "11.4") CommentTypes() { } - static { - COMMENT_TYPES = new int[NUMBER_OF_COMMENT_TYPES]; - COMMENT_TYPES[0] = CodeUnit.PRE_COMMENT; - COMMENT_TYPES[1] = CodeUnit.POST_COMMENT; - COMMENT_TYPES[2] = CodeUnit.EOL_COMMENT; - COMMENT_TYPES[3] = CodeUnit.PLATE_COMMENT; - COMMENT_TYPES[4] = CodeUnit.REPEATABLE_COMMENT; - } - /** * {@return an array containing the comment types on a code unit} */ + @Deprecated(forRemoval = true, since = "11.4") public static int[] getTypes() { - return COMMENT_TYPES; + CommentType[] types = CommentType.values(); + int[] ret = new int[types.length]; + for (int i = 0; i < types.length; i++) { + ret[i] = types[i].ordinal(); + } + return ret; } } diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/XReferenceUtil.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/XReferenceUtil.java index bc1d5294c4..ebba3d37ec 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/XReferenceUtil.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/XReferenceUtil.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -118,7 +118,7 @@ public class XReferenceUtil { // Check for thunk reference Function func = prog.getFunctionManager().getFunctionAt(cu.getMinAddress()); if (func != null) { - Address[] thunkAddrs = func.getFunctionThunkAddresses(); + Address[] thunkAddrs = func.getFunctionThunkAddresses(false); if (thunkAddrs != null) { for (Address thunkAddr : thunkAddrs) { xrefList.add(new ThunkReference(thunkAddr, func.getEntryPoint())); diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/golang/rtti/JsonPatch.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/golang/rtti/JsonPatch.java index 648e15497c..0f94be4075 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/golang/rtti/JsonPatch.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/golang/rtti/JsonPatch.java @@ -171,7 +171,7 @@ public class JsonPatch { private static PatchLine lineFromJson(JsonObject jsonObj) throws IOException { PatchOp op = jsonObj.get("op") instanceof JsonPrimitive prim - ? PatchOp.fromChar(prim.getAsCharacter()) + ? PatchOp.fromChar(prim.getAsString().charAt(0)) : null; JsonElement value = jsonObj.get("value"); if (op == null || op == PatchOp.ADD && value == null) { diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/xml/MarkupXmlMgr.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/xml/MarkupXmlMgr.java index afcdf01706..848e4b64e9 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/xml/MarkupXmlMgr.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/xml/MarkupXmlMgr.java @@ -331,7 +331,7 @@ class MarkupXmlMgr { // FIXME What do we need to do for externals in XML now? // FIXME SetExternalRefCmd addCmd = new SetExternalRefCmd(addr, opIndex, programName, label, - libAddr, userDefined ? SourceType.USER_DEFINED : SourceType.IMPORTED); + libAddr, RefType.DATA, userDefined ? SourceType.USER_DEFINED : SourceType.IMPORTED); addCmd.applyTo(program); // // if there happens to be a pointer here, then diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/xml/SymbolTableXmlMgr.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/xml/SymbolTableXmlMgr.java index a20fa46a98..06b5374169 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/xml/SymbolTableXmlMgr.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/xml/SymbolTableXmlMgr.java @@ -247,7 +247,7 @@ class SymbolTableXmlMgr { if (!f.isThunk()) { String thunkedName = name.substring(6); Symbol symbol = SymbolUtilities.getExpectedLabelOrFunctionSymbol(program, - thunkedName, err -> log.error(null, err)); + thunkedName, err -> log.appendMsg(err)); if (symbol == null || symbol.getSymbolType() != SymbolType.FUNCTION) { log.appendMsg( "Failed to establish thunk function for function at: " + addr); diff --git a/Ghidra/Features/Base/src/main/java/ghidra/program/util/DiffUtility.java b/Ghidra/Features/Base/src/main/java/ghidra/program/util/DiffUtility.java index 12d5de6891..5f3e8a754a 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/program/util/DiffUtility.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/program/util/DiffUtility.java @@ -94,9 +94,9 @@ public class DiffUtility extends SimpleDiffUtility { if (otherSpace == null) { return null; } - Range r = Range.between(range.getMinAddress().getOffset(), + Range r = Range.of(range.getMinAddress().getOffset(), range.getMaxAddress().getOffset(), unsignedLongComparator); - Range otherSpaceRange = Range.between(otherSpace.getMinAddress().getOffset(), + Range otherSpaceRange = Range.of(otherSpace.getMinAddress().getOffset(), otherSpace.getMaxAddress().getOffset(), unsignedLongComparator); if (!r.isOverlappedBy(otherSpaceRange)) { return null; diff --git a/Ghidra/Features/Base/src/test.slow/java/docking/widgets/dialogs/BigIntegerNumberInputDialogTest.java b/Ghidra/Features/Base/src/test.slow/java/docking/widgets/dialogs/BigIntegerNumberInputDialogTest.java index 102be2febf..06a15299d0 100644 --- a/Ghidra/Features/Base/src/test.slow/java/docking/widgets/dialogs/BigIntegerNumberInputDialogTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/docking/widgets/dialogs/BigIntegerNumberInputDialogTest.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,6 +15,7 @@ */ package docking.widgets.dialogs; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/clipboard/CodeBrowserClipboardProviderTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/clipboard/CodeBrowserClipboardProviderTest.java index 6b1977b444..2d9b6bb351 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/clipboard/CodeBrowserClipboardProviderTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/clipboard/CodeBrowserClipboardProviderTest.java @@ -15,6 +15,7 @@ */ package ghidra.app.plugin.core.clipboard; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsInstanceOf.*; import static org.junit.Assert.*; diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/data/ApplyDataTypeToBrowserTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/data/ApplyDataTypeToBrowserTest.java index 768eb98099..f36c852d09 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/data/ApplyDataTypeToBrowserTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/data/ApplyDataTypeToBrowserTest.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,6 +15,7 @@ */ package ghidra.app.plugin.core.data; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.StringContains.*; import static org.junit.Assert.*; diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/functionwindow/FunctionWindowPluginTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/functionwindow/FunctionWindowPluginTest.java index 690e4e285f..85259c2e27 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/functionwindow/FunctionWindowPluginTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/functionwindow/FunctionWindowPluginTest.java @@ -16,6 +16,7 @@ package ghidra.app.plugin.core.functionwindow; import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.*; import java.util.List; diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/navigation/locationreferences/ArrayLocationReferencesTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/navigation/locationreferences/ArrayLocationReferencesTest.java index 6e53944593..3c39236428 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/navigation/locationreferences/ArrayLocationReferencesTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/navigation/locationreferences/ArrayLocationReferencesTest.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,6 +18,7 @@ package ghidra.app.plugin.core.navigation.locationreferences; import static ghidra.GhidraOptions.*; import static ghidra.app.util.viewer.format.FormatManager.*; import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.*; import java.util.Arrays; diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/string/StringTableProviderTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/string/StringTableProviderTest.java index 171eeb9abf..9a8746a7c7 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/string/StringTableProviderTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/string/StringTableProviderTest.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,6 +16,7 @@ package ghidra.app.plugin.core.string; import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.*; import java.nio.charset.StandardCharsets; diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/framework/plugintool/dialog/ManagePlugins2Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/framework/plugintool/dialog/ManagePlugins2Test.java index ab2ad9cd29..d81f6e1d78 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/framework/plugintool/dialog/ManagePlugins2Test.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/framework/plugintool/dialog/ManagePlugins2Test.java @@ -15,8 +15,9 @@ */ package ghidra.framework.plugintool.dialog; -import static org.hamcrest.collection.IsEmptyCollection.empty; -import static org.hamcrest.core.IsNot.not; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.collection.IsEmptyCollection.*; +import static org.hamcrest.core.IsNot.*; import static org.junit.Assert.*; import java.util.*; diff --git a/Ghidra/Features/Base/src/test/java/ghidra/app/plugin/core/checksums/MyTestMemory.java b/Ghidra/Features/Base/src/test/java/ghidra/app/plugin/core/checksums/MyTestMemory.java index e8e98c6ae6..526adadf9a 100644 --- a/Ghidra/Features/Base/src/test/java/ghidra/app/plugin/core/checksums/MyTestMemory.java +++ b/Ghidra/Features/Base/src/test/java/ghidra/app/plugin/core/checksums/MyTestMemory.java @@ -46,11 +46,6 @@ public class MyTestMemory extends AddressSet implements Memory { throw new UnsupportedOperationException(); } - @Override - public AddressSetView getInitializedAddressSet() { - throw new UnsupportedOperationException(); - } - @Override public AddressSetView getAllInitializedAddressSet() { throw new UnsupportedOperationException(); diff --git a/Ghidra/Features/Base/src/test/java/ghidra/features/base/replace/AbstractSearchAndReplaceTest.java b/Ghidra/Features/Base/src/test/java/ghidra/features/base/replace/AbstractSearchAndReplaceTest.java index 26069842c3..f2c4665605 100644 --- a/Ghidra/Features/Base/src/test/java/ghidra/features/base/replace/AbstractSearchAndReplaceTest.java +++ b/Ghidra/Features/Base/src/test/java/ghidra/features/base/replace/AbstractSearchAndReplaceTest.java @@ -171,7 +171,7 @@ public class AbstractSearchAndReplaceTest extends AbstractGhidraHeadedIntegratio } protected void createComment(long address, CommentType commentType, String comment) { - builder.createComment(Long.toHexString(address), comment, commentType.ordinal()); + builder.createComment(Long.toHexString(address), comment, commentType); } protected void setSearchTypes(SearchType... searchTypes) { diff --git a/Ghidra/Features/ByteViewer/src/test.slow/java/ghidra/app/plugin/core/byteviewer/ByteViewerClipboardProviderTest.java b/Ghidra/Features/ByteViewer/src/test.slow/java/ghidra/app/plugin/core/byteviewer/ByteViewerClipboardProviderTest.java index 6618d4dfb8..9da425b5a0 100644 --- a/Ghidra/Features/ByteViewer/src/test.slow/java/ghidra/app/plugin/core/byteviewer/ByteViewerClipboardProviderTest.java +++ b/Ghidra/Features/ByteViewer/src/test.slow/java/ghidra/app/plugin/core/byteviewer/ByteViewerClipboardProviderTest.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,6 +15,7 @@ */ package ghidra.app.plugin.core.byteviewer; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsInstanceOf.*; import static org.junit.Assert.*; diff --git a/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/service/FidProgramSeeker.java b/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/service/FidProgramSeeker.java index 7d30f48618..be7c380ac2 100644 --- a/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/service/FidProgramSeeker.java +++ b/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/service/FidProgramSeeker.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -149,7 +149,7 @@ public class FidProgramSeeker { Address curAddr = function.getEntryPoint(); Address[] thunkAddresses = null; if (followThunks) { - thunkAddresses = function.getFunctionThunkAddresses(); + thunkAddresses = function.getFunctionThunkAddresses(false); if (thunkAddresses != null) { size = thunkAddresses.length; } diff --git a/Ghidra/Features/PDB/developer_scripts/PdbQueryOpenScript.java b/Ghidra/Features/PDB/developer_scripts/PdbQueryOpenScript.java index 3be06c4515..8a900fd890 100644 --- a/Ghidra/Features/PDB/developer_scripts/PdbQueryOpenScript.java +++ b/Ghidra/Features/PDB/developer_scripts/PdbQueryOpenScript.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,7 +19,7 @@ import java.io.File; -import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Strings; import ghidra.app.script.GhidraScript; import ghidra.app.util.bin.format.pdb2.pdbreader.PdbIdentifiers; @@ -42,7 +42,7 @@ public class PdbQueryOpenScript extends GhidraScript { println("Aborting: " + pdbFilename + " is not a valid file."); return; } - if (!StringUtils.endsWithIgnoreCase(pdbFilename, ".pdb")) { + if (!Strings.CI.endsWith(pdbFilename, ".pdb")) { println("Aborting: filename missing .pdb extension: " + pdbFilename); return; } diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/SymbolRecords.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/SymbolRecords.java index 29a33431ef..d2b7601366 100644 --- a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/SymbolRecords.java +++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/bin/format/pdb2/pdbreader/SymbolRecords.java @@ -87,7 +87,7 @@ public class SymbolRecords { * @throws PdbException upon not enough data left to parse * @throws CancelledException upon user cancellation */ - @Deprecated + @Deprecated(since = "11.0") protected Map getModuleSymbolsByOffset(int moduleNumber) throws CancelledException, IOException, PdbException { PdbDebugInfo debugInfo = pdb.getDebugInfo(); diff --git a/Ghidra/Features/PDB/src/main/java/pdb/PdbPlugin.java b/Ghidra/Features/PDB/src/main/java/pdb/PdbPlugin.java index 7c601ac19f..9061f37d72 100644 --- a/Ghidra/Features/PDB/src/main/java/pdb/PdbPlugin.java +++ b/Ghidra/Features/PDB/src/main/java/pdb/PdbPlugin.java @@ -76,21 +76,21 @@ public class PdbPlugin extends Plugin { private void createActions() { new ActionBuilder("Load PDB File", this.getName()) - .withContext(ProgramActionContext.class, true) - .validContextWhen(pac -> pac.getProgram() != null && - PdbAnalyzerCommon.canAnalyzeProgram(pac.getProgram())) - .menuPath(ToolConstants.MENU_FILE, "Load PDB File...") - .menuGroup("Import PDB", "3") - .helpLocation(new HelpLocation(PDB_PLUGIN_HELP_TOPIC, "Load PDB File")) - .onAction(pac -> loadPDB(pac)) - .buildAndInstall(tool); + .withContext(ProgramActionContext.class, true) + .validWhen(pac -> pac.getProgram() != null && + PdbAnalyzerCommon.canAnalyzeProgram(pac.getProgram())) + .menuPath(ToolConstants.MENU_FILE, "Load PDB File...") + .menuGroup("Import PDB", "3") + .helpLocation(new HelpLocation(PDB_PLUGIN_HELP_TOPIC, "Load PDB File")) + .onAction(pac -> loadPDB(pac)) + .buildAndInstall(tool); new ActionBuilder("Symbol Server Config", this.getName()) - .menuPath(ToolConstants.MENU_EDIT, "Symbol Server Config") - .menuGroup(ToolConstants.TOOL_OPTIONS_MENU_GROUP) - .helpLocation(new HelpLocation(PDB_PLUGIN_HELP_TOPIC, "Symbol Server Config")) - .onAction(ac -> configPDB()) - .buildAndInstall(tool); + .menuPath(ToolConstants.MENU_EDIT, "Symbol Server Config") + .menuGroup(ToolConstants.TOOL_OPTIONS_MENU_GROUP) + .helpLocation(new HelpLocation(PDB_PLUGIN_HELP_TOPIC, "Symbol Server Config")) + .onAction(ac -> configPDB()) + .buildAndInstall(tool); } private void configPDB() { diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/VTAbstractReferenceProgramCorrelator.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/VTAbstractReferenceProgramCorrelator.java index e659c603d4..2b320d0f84 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/VTAbstractReferenceProgramCorrelator.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/correlator/program/VTAbstractReferenceProgramCorrelator.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -308,7 +308,7 @@ public abstract class VTAbstractReferenceProgramCorrelator extends VTAbstractPro FunctionManager functionManager = program.getFunctionManager(); Function addressFunction = functionManager.getFunctionAt(address); if (addressFunction != null) { - Address[] thunkAddresses = addressFunction.getFunctionThunkAddresses(); + Address[] thunkAddresses = addressFunction.getFunctionThunkAddresses(false); if (thunkAddresses != null) { for (Address thunkAddress : thunkAddresses) { accumulateFunctionReferences(depth + 1, list, program, thunkAddress); diff --git a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/markuptype/CommentMarkupType.java b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/markuptype/CommentMarkupType.java index 7722289b6e..31adbbb610 100644 --- a/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/markuptype/CommentMarkupType.java +++ b/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/markuptype/CommentMarkupType.java @@ -18,7 +18,7 @@ package ghidra.feature.vt.api.markuptype; import java.util.ArrayList; import java.util.List; -import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Strings; import ghidra.feature.vt.api.impl.MarkupItemImpl; import ghidra.feature.vt.api.main.*; @@ -134,7 +134,7 @@ public abstract class CommentMarkupType extends VTMarkupType { CommentType commentType = getCodeUnitCommentType(); Listing destinationListing = getDestinationListing(markupItem.getAssociation()); String comment = destinationListing.getComment(commentType, destinationAddress); - if (!StringUtils.equals(originalDestinationComment, comment)) { + if (!Strings.CS.equals(originalDestinationComment, comment)) { destinationListing.setComment(destinationAddress, commentType, originalDestinationComment); } diff --git a/Ghidra/Features/VersionTrackingBSim/src/test/java/ghidra/feature/vt/api/BSimSelfSimilarCorrelatorTest.java b/Ghidra/Features/VersionTrackingBSim/src/test/java/ghidra/feature/vt/api/BSimSelfSimilarCorrelatorTest.java index 0d427d15c2..2ed0124ae0 100755 --- a/Ghidra/Features/VersionTrackingBSim/src/test/java/ghidra/feature/vt/api/BSimSelfSimilarCorrelatorTest.java +++ b/Ghidra/Features/VersionTrackingBSim/src/test/java/ghidra/feature/vt/api/BSimSelfSimilarCorrelatorTest.java @@ -16,14 +16,10 @@ */ package ghidra.feature.vt.api; -import ghidra.program.model.address.Address; -import ghidra.program.model.address.AddressFactory; -import ghidra.program.model.address.AddressSet; -import ghidra.program.model.address.AddressSetView; -import ghidra.program.model.address.AddressSpace; - import org.junit.Test; +import ghidra.program.model.address.*; + public class BSimSelfSimilarCorrelatorTest extends AbstractSelfSimilarCorrelatorTest { public BSimSelfSimilarCorrelatorTest( ) { super(); @@ -40,7 +36,7 @@ public class BSimSelfSimilarCorrelatorTest extends AbstractSelfSimilarCorrelator AddressFactory addressFactory = sourceProgram.getAddressFactory(); AddressSpace addressSpace = addressFactory.getDefaultAddressSpace(); AddressSet set = - new AddressSet(sourceProgram.getMemory().getInitializedAddressSet()); + new AddressSet(sourceProgram.getMemory().getLoadedAndInitializedAddressSet()); for (long l : addresses) { Address address = addressSpace.getAddress(l); set = set.subtract(new AddressSet(address, address)); diff --git a/Ghidra/Features/WildcardAssembler/src/test/java/ghidra/asm/wild/WildSleighAssemblerTest.java b/Ghidra/Features/WildcardAssembler/src/test/java/ghidra/asm/wild/WildSleighAssemblerTest.java index b382baf544..2ca896b2c9 100644 --- a/Ghidra/Features/WildcardAssembler/src/test/java/ghidra/asm/wild/WildSleighAssemblerTest.java +++ b/Ghidra/Features/WildcardAssembler/src/test/java/ghidra/asm/wild/WildSleighAssemblerTest.java @@ -15,6 +15,7 @@ */ package ghidra.asm.wild; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/filter/MatchesPatternTextFilter.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/filter/MatchesPatternTextFilter.java index d91f03aa94..42526bfe60 100644 --- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/filter/MatchesPatternTextFilter.java +++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/filter/MatchesPatternTextFilter.java @@ -17,7 +17,7 @@ package docking.widgets.filter; import java.util.regex.Pattern; -import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Strings; /** * A text filter that uses a pattern and performs a 'matches' using that pattern. @@ -41,7 +41,7 @@ public abstract class MatchesPatternTextFilter extends AbstractPatternTextFilter // Handle escaped glob characters. A previous filter result that ends with an escape // character will not have correctly matched the items being filtered. Thus, we cannot // be a sub filter such a parent filter. - boolean endsWithEscapedGlob = StringUtils.endsWithAny(filterText, "\\?", "\\*"); + boolean endsWithEscapedGlob = Strings.CS.endsWithAny(filterText, "\\?", "\\*"); if (endsWithEscapedGlob) { // If the user type slow enough (to let the SwingUpdateManager run) in the filter // field, then the parent filter will end with a backslash. If they user types fast diff --git a/Ghidra/Framework/Docking/src/test.slow/java/docking/widgets/table/threaded/DefaultThreadedTableFilterTest.java b/Ghidra/Framework/Docking/src/test.slow/java/docking/widgets/table/threaded/DefaultThreadedTableFilterTest.java index dc84935048..6dbb65f1d6 100644 --- a/Ghidra/Framework/Docking/src/test.slow/java/docking/widgets/table/threaded/DefaultThreadedTableFilterTest.java +++ b/Ghidra/Framework/Docking/src/test.slow/java/docking/widgets/table/threaded/DefaultThreadedTableFilterTest.java @@ -16,6 +16,7 @@ package docking.widgets.table.threaded; import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.*; import java.awt.BorderLayout; diff --git a/Ghidra/Framework/Docking/src/test.slow/java/docking/widgets/textfield/HexOrDecimalInputTest.java b/Ghidra/Framework/Docking/src/test.slow/java/docking/widgets/textfield/HexOrDecimalInputTest.java index b3a8f904c9..3d08e3c205 100644 --- a/Ghidra/Framework/Docking/src/test.slow/java/docking/widgets/textfield/HexOrDecimalInputTest.java +++ b/Ghidra/Framework/Docking/src/test.slow/java/docking/widgets/textfield/HexOrDecimalInputTest.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,9 +15,8 @@ */ package docking.widgets.textfield; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.MatcherAssert.*; import java.awt.*; import java.awt.RenderingHints.Key; diff --git a/Ghidra/Framework/Docking/src/test/java/docking/widgets/table/threaded/AbstractThreadedTableTest.java b/Ghidra/Framework/Docking/src/test/java/docking/widgets/table/threaded/AbstractThreadedTableTest.java index 6914c05c49..d3b2c1114a 100644 --- a/Ghidra/Framework/Docking/src/test/java/docking/widgets/table/threaded/AbstractThreadedTableTest.java +++ b/Ghidra/Framework/Docking/src/test/java/docking/widgets/table/threaded/AbstractThreadedTableTest.java @@ -16,6 +16,7 @@ package docking.widgets.table.threaded; import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.*; import java.awt.BorderLayout; diff --git a/Ghidra/Framework/Generic/src/main/java/generic/test/ConcurrentTestExceptionHandler.java b/Ghidra/Framework/Generic/src/main/java/generic/test/ConcurrentTestExceptionHandler.java index d24b765c0a..55c1840dcf 100644 --- a/Ghidra/Framework/Generic/src/main/java/generic/test/ConcurrentTestExceptionHandler.java +++ b/Ghidra/Framework/Generic/src/main/java/generic/test/ConcurrentTestExceptionHandler.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,7 +19,7 @@ import java.lang.Thread.UncaughtExceptionHandler; import java.lang.reflect.InvocationTargetException; import java.util.*; -import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Strings; import ghidra.util.Msg; import ghidra.util.Swing; @@ -96,7 +96,7 @@ public class ConcurrentTestExceptionHandler implements UncaughtExceptionHandler return false; } - return StringUtils.containsAny(message, IGNORABLE_ERROR_MESSAGES); + return Strings.CS.containsAny(message, IGNORABLE_ERROR_MESSAGES); } /** diff --git a/Ghidra/Framework/Generic/src/main/java/ghidra/framework/LoggingInitialization.java b/Ghidra/Framework/Generic/src/main/java/ghidra/framework/LoggingInitialization.java index 5441342f59..611bb4a35b 100644 --- a/Ghidra/Framework/Generic/src/main/java/ghidra/framework/LoggingInitialization.java +++ b/Ghidra/Framework/Generic/src/main/java/ghidra/framework/LoggingInitialization.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -108,8 +108,9 @@ public class LoggingInitialization { if (!configFile.exists()) { // maybe it is already in URL form: file://some/file/path try { - URL url = new URL(configString); - File file = new File(url.toURI()); + URI uri = new URI(configString); + URL url = uri.toURL(); + File file = new File(uri); if (file.exists()) { return url; } diff --git a/Ghidra/Framework/Generic/src/main/java/ghidra/net/http/HttpUtil.java b/Ghidra/Framework/Generic/src/main/java/ghidra/net/http/HttpUtil.java index a7ca34f27b..8f0712aa90 100644 --- a/Ghidra/Framework/Generic/src/main/java/ghidra/net/http/HttpUtil.java +++ b/Ghidra/Framework/Generic/src/main/java/ghidra/net/http/HttpUtil.java @@ -31,13 +31,14 @@ public class HttpUtil { * @param allowRedirect allow site redirects to be handled if true * @return HttpURLConnection which contains information about the URL * @throws MalformedURLException bad httpUrlString specified + * @throws URISyntaxException bad httpUrlString specified * @throws IOException if an error occurs while executing request */ public static HttpURLConnection getContent(String httpUrlString, Properties httpRequestProperties, boolean allowRedirect) - throws MalformedURLException, IOException { + throws MalformedURLException, URISyntaxException, IOException { - URL url = new URL(httpUrlString); + URL url = new URI(httpUrlString).toURL(); String protocol = url.getProtocol(); if ("https".equals(protocol)) { @@ -97,11 +98,13 @@ public class HttpUtil { * @param allowRedirect allow site redirects to be handled if true * @param destFile destination file * @throws MalformedURLException bad httpUrlString specified + * @throws URISyntaxException bad httpUrlString specified * @throws IOException if an error occurs while executing request * @return String representing the content-type of the file, or null if the information is not available */ public static String getFile(String httpUrlString, Properties httpRequestProperties, - boolean allowRedirect, File destFile) throws MalformedURLException, IOException { + boolean allowRedirect, File destFile) + throws MalformedURLException, URISyntaxException, IOException { HttpURLConnection connection = null; InputStream content = null; diff --git a/Ghidra/Framework/Generic/src/main/java/ghidra/util/JavaSourceFile.java b/Ghidra/Framework/Generic/src/main/java/ghidra/util/JavaSourceFile.java index 3149f42ba9..71d57895ed 100644 --- a/Ghidra/Framework/Generic/src/main/java/ghidra/util/JavaSourceFile.java +++ b/Ghidra/Framework/Generic/src/main/java/ghidra/util/JavaSourceFile.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.List; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Strings; public class JavaSourceFile { @@ -303,7 +304,7 @@ public class JavaSourceFile { if (nameAndMaybeDeclaraction.length == 2) { return nameAndMaybeDeclaraction[0].endsWith("Action"); } - return StringUtils.containsIgnoreCase(nameAndMaybeDeclaraction[0], "action"); + return Strings.CI.contains(nameAndMaybeDeclaraction[0], "action"); } private JavaSourceLine findEndOfUnknownLine(int lineNumber) { diff --git a/Ghidra/Framework/Generic/src/main/java/ghidra/util/StringUtilities.java b/Ghidra/Framework/Generic/src/main/java/ghidra/util/StringUtilities.java index 940e86a1c5..7199d2b40f 100644 --- a/Ghidra/Framework/Generic/src/main/java/ghidra/util/StringUtilities.java +++ b/Ghidra/Framework/Generic/src/main/java/ghidra/util/StringUtilities.java @@ -20,8 +20,7 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.commons.lang3.ArrayUtils; -import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.*; import generic.json.Json; @@ -370,7 +369,7 @@ public class StringUtilities { } for (CharSequence search : searches) { - if (!StringUtils.contains(toSearch, search)) { + if (!Strings.CS.contains(toSearch, search)) { return false; } } @@ -391,7 +390,7 @@ public class StringUtilities { } for (CharSequence search : searches) { - if (!StringUtils.containsIgnoreCase(toSearch, search)) { + if (!Strings.CI.contains(toSearch, search)) { return false; } } @@ -412,7 +411,7 @@ public class StringUtilities { } for (CharSequence search : searches) { - if (StringUtils.containsIgnoreCase(toSearch, search)) { + if (Strings.CI.contains(toSearch, search)) { return true; } } diff --git a/Ghidra/Framework/Generic/src/main/java/ghidra/util/xml/XmlUtilities.java b/Ghidra/Framework/Generic/src/main/java/ghidra/util/xml/XmlUtilities.java index c1b332e3d6..7b3b9eb418 100644 --- a/Ghidra/Framework/Generic/src/main/java/ghidra/util/xml/XmlUtilities.java +++ b/Ghidra/Framework/Generic/src/main/java/ghidra/util/xml/XmlUtilities.java @@ -27,6 +27,7 @@ import javax.xml.parsers.SAXParserFactory; import org.jdom2.*; import org.jdom2.input.SAXBuilder; +import org.jdom2.input.sax.XMLReaderSAX2Factory; import org.jdom2.output.Format; import org.jdom2.output.XMLOutputter; import org.xml.sax.*; @@ -667,8 +668,7 @@ public class XmlUtilities { */ public static SAXBuilder createSecureSAXBuilder(boolean validate, boolean needsDTD) { final String IMPLNAME = "com.sun.org.apache.xerces.internal.parsers.SAXParser"; - SAXBuilder sax = new SAXBuilder(IMPLNAME, validate); - sax.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); + SAXBuilder sax = new SAXBuilder(new XMLReaderSAX2Factory(validate, IMPLNAME)); // XML Program Import uses DTD if (!needsDTD) { sax.setFeature(FEATURE_DISALLOW_DTD, true); diff --git a/Ghidra/Framework/Generic/src/test/java/ghidra/net/http/HttpUtilTest.java b/Ghidra/Framework/Generic/src/test/java/ghidra/net/http/HttpUtilTest.java index b61fce7e1b..4661180068 100644 --- a/Ghidra/Framework/Generic/src/test/java/ghidra/net/http/HttpUtilTest.java +++ b/Ghidra/Framework/Generic/src/test/java/ghidra/net/http/HttpUtilTest.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,11 +15,11 @@ */ package ghidra.net.http; -import java.util.Properties; - import java.io.File; import java.io.IOException; import java.net.MalformedURLException; +import java.net.URISyntaxException; +import java.util.Properties; public class HttpUtilTest { public static void main(String[] args) { @@ -37,7 +37,7 @@ public class HttpUtilTest { HttpUtil.getFile(urlStr, properties, true, f); System.out.println("getFile completed: " + f); } - catch (MalformedURLException e) { + catch (MalformedURLException | URISyntaxException e) { e.printStackTrace(); } catch (IOException e) { diff --git a/Ghidra/Framework/Generic/src/test/java/util/CollectionUtilsTest.java b/Ghidra/Framework/Generic/src/test/java/util/CollectionUtilsTest.java index 9dfb756e31..4d6d5e62d1 100644 --- a/Ghidra/Framework/Generic/src/test/java/util/CollectionUtilsTest.java +++ b/Ghidra/Framework/Generic/src/test/java/util/CollectionUtilsTest.java @@ -15,6 +15,7 @@ */ package util; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; import static org.hamcrest.collection.IsIn.oneOf; import static org.junit.Assert.*; diff --git a/Ghidra/Framework/Generic/src/test/java/utilities/util/FileUtilitiesTest.java b/Ghidra/Framework/Generic/src/test/java/utilities/util/FileUtilitiesTest.java index b4fc672606..89685a394e 100644 --- a/Ghidra/Framework/Generic/src/test/java/utilities/util/FileUtilitiesTest.java +++ b/Ghidra/Framework/Generic/src/test/java/utilities/util/FileUtilitiesTest.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,6 +17,7 @@ package utilities.util; import static generic.test.AbstractGTest.*; import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.*; import java.io.*; diff --git a/Ghidra/Framework/Generic/src/test/java/utilities/util/reflection/ReflectionUtilitiesTest.java b/Ghidra/Framework/Generic/src/test/java/utilities/util/reflection/ReflectionUtilitiesTest.java index 3256037d87..f32109b8a6 100644 --- a/Ghidra/Framework/Generic/src/test/java/utilities/util/reflection/ReflectionUtilitiesTest.java +++ b/Ghidra/Framework/Generic/src/test/java/utilities/util/reflection/ReflectionUtilitiesTest.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,6 +16,7 @@ package utilities.util.reflection; import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.*; import java.util.ArrayList; diff --git a/Ghidra/Framework/Graph/src/test.slow/java/ghidra/graph/job/FilterVerticesJobTest.java b/Ghidra/Framework/Graph/src/test.slow/java/ghidra/graph/job/FilterVerticesJobTest.java index 2c5c4f10bb..0e7c44cfcb 100644 --- a/Ghidra/Framework/Graph/src/test.slow/java/ghidra/graph/job/FilterVerticesJobTest.java +++ b/Ghidra/Framework/Graph/src/test.slow/java/ghidra/graph/job/FilterVerticesJobTest.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,7 +15,7 @@ */ package ghidra.graph.job; -import static org.junit.Assert.assertEquals; +import static org.junit.Assert.*; import java.awt.Dimension; import java.util.Set; @@ -23,7 +23,7 @@ import java.util.function.Predicate; import javax.swing.JFrame; -import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Strings; import org.junit.Before; import org.junit.Test; @@ -268,7 +268,7 @@ public class FilterVerticesJobTest extends AbstractFilteringVisualGraphTest { } private void filter(String filterText, boolean remove, int filterDuration) { - Predicate filter = v -> StringUtils.containsIgnoreCase(v.getName(), filterText); + Predicate filter = v -> Strings.CI.contains(v.getName(), filterText); FilterVerticesJob job = new FilterVerticesJob<>(viewer, graph, filter, remove); job.duration = filterDuration; @@ -277,7 +277,7 @@ public class FilterVerticesJobTest extends AbstractFilteringVisualGraphTest { } private void filterSlowly(String filterText, boolean remove) { - Predicate filter = v -> StringUtils.containsIgnoreCase(v.getName(), filterText); + Predicate filter = v -> Strings.CI.contains(v.getName(), filterText); FilterVerticesJob job = new FilterVerticesJob(viewer, graph, filter, remove) { diff --git a/Ghidra/Framework/Graph/src/test/java/ghidra/graph/GraphAlgorithmsTest.java b/Ghidra/Framework/Graph/src/test/java/ghidra/graph/GraphAlgorithmsTest.java index 3c0a495940..79b5b546c4 100644 --- a/Ghidra/Framework/Graph/src/test/java/ghidra/graph/GraphAlgorithmsTest.java +++ b/Ghidra/Framework/Graph/src/test/java/ghidra/graph/GraphAlgorithmsTest.java @@ -18,6 +18,7 @@ package ghidra.graph; import static org.hamcrest.CoreMatchers.hasItem; import static org.hamcrest.CoreMatchers.hasItems; import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; diff --git a/Ghidra/Framework/Gui/src/main/java/resources/ResourceManager.java b/Ghidra/Framework/Gui/src/main/java/resources/ResourceManager.java index d34ef15545..c94025adf8 100644 --- a/Ghidra/Framework/Gui/src/main/java/resources/ResourceManager.java +++ b/Ghidra/Framework/Gui/src/main/java/resources/ResourceManager.java @@ -28,7 +28,7 @@ import java.util.stream.Collectors; import javax.swing.*; -import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Strings; import generic.theme.GIcon; import ghidra.framework.Application; @@ -217,7 +217,7 @@ public class ResourceManager { // now search the path entries for (String path : paths) { - if (!StringUtils.endsWithAny(path.toLowerCase(), ".jar", ".zip")) { + if (!Strings.CI.endsWithAny(path, ".jar", ".zip")) { // maybe a directory String classpathDirectoryEntry = path + File.separator + resourceDirName; @@ -657,8 +657,8 @@ public class ResourceManager { private static void filterImages(Set set) { Iterator it = set.iterator(); while (it.hasNext()) { - String filename = it.next().toLowerCase(); - if (!StringUtils.endsWithAny(filename, ".gif", ".jpg", ".png")) { + String filename = it.next(); + if (!Strings.CI.endsWithAny(filename, ".gif", ".jpg", ".png")) { it.remove(); } } diff --git a/Ghidra/Framework/Help/src/main/java/help/CustomTOCView.java b/Ghidra/Framework/Help/src/main/java/help/CustomTOCView.java index 8b5841137b..daaaedbd45 100644 --- a/Ghidra/Framework/Help/src/main/java/help/CustomTOCView.java +++ b/Ghidra/Framework/Help/src/main/java/help/CustomTOCView.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,8 +16,7 @@ package help; import java.awt.Component; -import java.net.MalformedURLException; -import java.net.URL; +import java.net.*; import java.util.*; import javax.help.*; @@ -281,10 +280,10 @@ public class CustomTOCView extends TOCView { urlString = urlString.substring(0, anchorIndex); try { - URL newURL = new URL(urlString); + URL newURL = new URI(urlString).toURL(); selectNodeForID(newURL, null); } - catch (MalformedURLException e) { + catch (MalformedURLException | URISyntaxException e) { // shouldn't happen, as we are starting with a valid URL Msg.debug(this, "Unexpected error create a help URL from an existing URL: " + urlString, e); diff --git a/Ghidra/Framework/Help/src/main/java/help/GHelpSet.java b/Ghidra/Framework/Help/src/main/java/help/GHelpSet.java index 3a0c4c8282..68220e7bbd 100644 --- a/Ghidra/Framework/Help/src/main/java/help/GHelpSet.java +++ b/Ghidra/Framework/Help/src/main/java/help/GHelpSet.java @@ -17,8 +17,7 @@ package help; import java.io.IOException; import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; +import java.net.*; import java.util.Enumeration; import java.util.Map.Entry; import java.util.Set; @@ -223,9 +222,9 @@ public class GHelpSet extends HelpSet { URL url = null; try { - url = new URL(id); + url = new URI(id).toURL(); } - catch (MalformedURLException e) { + catch (MalformedURLException | URISyntaxException e) { LOG.trace("ID is not a URL; tried to make URL from string: " + id); return null; } diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/ToolUtils.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/ToolUtils.java index 568bad7d20..f1a8033031 100644 --- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/ToolUtils.java +++ b/Ghidra/Framework/Project/src/main/java/ghidra/framework/ToolUtils.java @@ -18,7 +18,7 @@ package ghidra.framework; import java.io.*; import java.util.*; -import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Strings; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jdom2.*; @@ -325,7 +325,7 @@ public class ToolUtils { return false; } - if (StringUtils.containsIgnoreCase(toolName, "test")) { + if (Strings.CI.contains(toolName, "test")) { LOGGER.trace("Not adding default 'test' tool: " + toolName); return true; } diff --git a/Ghidra/Framework/Project/src/test/java/ghidra/framework/model/TestDummyDomainFile.java b/Ghidra/Framework/Project/src/test/java/ghidra/framework/model/TestDummyDomainFile.java index 94dd9180c2..8e8491d63c 100644 --- a/Ghidra/Framework/Project/src/test/java/ghidra/framework/model/TestDummyDomainFile.java +++ b/Ghidra/Framework/Project/src/test/java/ghidra/framework/model/TestDummyDomainFile.java @@ -23,7 +23,7 @@ import java.util.Map; import javax.swing.Icon; -import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Strings; import ghidra.framework.Application; import ghidra.framework.data.*; @@ -131,7 +131,7 @@ public class TestDummyDomainFile implements DomainFile, LinkFileInfo { @Override public String getPathname() { - String parentPathname = StringUtils.appendIfMissing(parent.getPathname(), "/"); + String parentPathname = Strings.CS.appendIfMissing(parent.getPathname(), "/"); return parentPathname + name; } diff --git a/Ghidra/Framework/Project/src/test/java/ghidra/framework/model/TestDummyDomainFolder.java b/Ghidra/Framework/Project/src/test/java/ghidra/framework/model/TestDummyDomainFolder.java index dadf407eea..850202a7a2 100644 --- a/Ghidra/Framework/Project/src/test/java/ghidra/framework/model/TestDummyDomainFolder.java +++ b/Ghidra/Framework/Project/src/test/java/ghidra/framework/model/TestDummyDomainFolder.java @@ -21,7 +21,7 @@ import java.net.URL; import java.util.ArrayList; import java.util.List; -import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Strings; import ghidra.framework.data.*; import ghidra.framework.store.FolderNotEmptyException; @@ -88,7 +88,7 @@ public class TestDummyDomainFolder implements DomainFolder { @Override public String getPathname() { if (parent != null) { - String parentPathname = StringUtils.appendIfMissing(parent.getPathname(), "/"); + String parentPathname = Strings.CS.appendIfMissing(parent.getPathname(), "/"); return parentPathname + folderName; } return "/"; diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/plugin/processors/sleigh/SleighLanguage.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/plugin/processors/sleigh/SleighLanguage.java index 3576bad85d..7c2ad0abf8 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/plugin/processors/sleigh/SleighLanguage.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/plugin/processors/sleigh/SleighLanguage.java @@ -1099,7 +1099,7 @@ public class SleighLanguage implements Language { * @deprecated Will be removed once we have better way to attach address spaces to pointer data-types * @return the default wordsize to use when analyzing pointer offsets */ - @Deprecated + @Deprecated(since = "9.0") public int getDefaultPointerWordSize() { return defaultPointerWordSize; } diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/PseudoCodeUnit.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/PseudoCodeUnit.java index 629201badc..845d8dd074 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/PseudoCodeUnit.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/PseudoCodeUnit.java @@ -410,9 +410,7 @@ abstract class PseudoCodeUnit implements CodeUnit { * * @throws ConcurrentModificationException * if this object is no longer valid. - * @deprecated */ - @Deprecated @Override public String getLabel() { if (program == null) diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/DBStringMapAdapter.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/DBStringMapAdapter.java index 613aeca2c6..1c32c18fef 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/DBStringMapAdapter.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/DBStringMapAdapter.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,7 +19,7 @@ import java.io.IOException; import java.util.HashSet; import java.util.Set; -import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Strings; import db.*; @@ -50,7 +50,7 @@ public class DBStringMapAdapter { } public void put(String key, String value) throws IOException { - if (StringUtils.equals(value, get(key))) { + if (Strings.CS.equals(value, get(key))) { return; } DBRecord record = SCHEMA.createRecord(new StringField(key)); diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/mem/FileBytes.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/mem/FileBytes.java index 7cd34a79e6..9cd77fec1a 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/mem/FileBytes.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/mem/FileBytes.java @@ -18,7 +18,7 @@ package ghidra.program.database.mem; import java.io.IOException; import java.util.ConcurrentModificationException; -import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Strings; import db.*; @@ -53,7 +53,7 @@ public class FileBytes { String f = record.getString(FileBytesAdapter.FILENAME_COL); long offset = record.getLongValue(FileBytesAdapter.OFFSET_COL); long sz = record.getLongValue(FileBytesAdapter.SIZE_COL); - if (offset != fileOffset || sz != size || !StringUtils.equals(f, filename)) { + if (offset != fileOffset || sz != size || !Strings.CS.equals(f, filename)) { return false; } diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/mem/MemoryMapDB.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/mem/MemoryMapDB.java index 3bc24fb0dd..39bf839059 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/mem/MemoryMapDB.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/mem/MemoryMapDB.java @@ -260,11 +260,6 @@ public class MemoryMapDB implements Memory, ManagerDB { return addrMap; } - @Override - public AddressSetView getInitializedAddressSet() { - return getLoadedAndInitializedAddressSet(); - } - @Override public AddressSetView getAllInitializedAddressSet() { MemoryAddressSetViews localAddrSetViews = getMemoryAddressSetViews(); diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/sourcemap/UserDataPathTransformer.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/sourcemap/UserDataPathTransformer.java index e3fab3204b..ab56a4babd 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/sourcemap/UserDataPathTransformer.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/sourcemap/UserDataPathTransformer.java @@ -21,6 +21,7 @@ import java.util.*; import java.util.Map.Entry; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Strings; import ghidra.framework.model.DomainObject; import ghidra.framework.model.DomainObjectClosedListener; @@ -202,7 +203,7 @@ public class UserDataPathTransformer implements SourcePathTransformer, DomainObj if (leftLength != rightLength) { return Integer.compare(leftLength, rightLength); } - return StringUtils.compare(left, right); + return Strings.CS.compare(left, right); } private void reloadMaps() { diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/listing/Function.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/listing/Function.java index 386b71bf3b..b88d111d8c 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/listing/Function.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/listing/Function.java @@ -682,7 +682,7 @@ public interface Function extends Namespace { * a recursive search is generally needed (see {@link #getFunctionThunkAddresses(boolean)}). * This method form may be removed in a future release. */ - @Deprecated(since = "10.2") + @Deprecated(since = "10.2", forRemoval = true) public default Address[] getFunctionThunkAddresses() { return getFunctionThunkAddresses(false); } diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/listing/VariableImpl.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/listing/VariableImpl.java index 9d0a9fc22f..1079ffc665 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/listing/VariableImpl.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/listing/VariableImpl.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,7 +18,7 @@ package ghidra.program.model.listing; import java.util.ArrayList; import java.util.List; -import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Strings; import ghidra.program.database.data.DataTypeUtilities; import ghidra.program.model.address.Address; @@ -485,10 +485,10 @@ abstract class VariableImpl implements Variable { if (!isEquivalent(otherVar)) { return false; } - if (!StringUtils.equals(name, otherVar.getName())) { + if (!Strings.CS.equals(name, otherVar.getName())) { return false; } - return StringUtils.equals(comment, otherVar.getComment()); + return Strings.CS.equals(comment, otherVar.getComment()); } @Override diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/mem/Memory.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/mem/Memory.java index 4fe26964ff..93151e5223 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/mem/Memory.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/mem/Memory.java @@ -116,15 +116,6 @@ public interface Memory extends AddressSetView { */ public AddressSetView getAllInitializedAddressSet(); - /** - * {@return the set of addresses which correspond to all the "loaded" memory blocks that have - * initialized data.} This does not include initialized memory blocks that contain data from - * the program's file header such as debug sections. - * @deprecated Use {@link #getLoadedAndInitializedAddressSet} instead - */ - @Deprecated - public AddressSetView getInitializedAddressSet(); - /** * {@return the set of addresses which correspond to the executable memory} */ diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/mem/StubMemory.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/mem/StubMemory.java index aad0ffc499..3800cc66e4 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/mem/StubMemory.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/mem/StubMemory.java @@ -159,11 +159,6 @@ public class StubMemory extends AddressSet implements Memory { throw new UnsupportedOperationException(); } - @Override - public AddressSetView getInitializedAddressSet() { - throw new UnsupportedOperationException(); - } - @Override public AddressSetView getExecuteSet() { throw new UnsupportedOperationException(); diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/util/SimpleDiffUtility.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/util/SimpleDiffUtility.java index ff98780b63..4672b38b8e 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/util/SimpleDiffUtility.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/util/SimpleDiffUtility.java @@ -729,7 +729,7 @@ public class SimpleDiffUtility { // Process thunk-references (include all) if (extLoc.isFunction()) { - Address[] thunkAddrs = extLoc.getFunction().getFunctionThunkAddresses(); + Address[] thunkAddrs = extLoc.getFunction().getFunctionThunkAddresses(false); if (thunkAddrs != null) { for (Address thunkAddr : thunkAddrs) { Symbol otherThunkSym = otherSymbMgr.getPrimarySymbol(thunkAddr); diff --git a/Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/lldb/rmi/LldbConnectorsTest.java b/Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/lldb/rmi/LldbConnectorsTest.java index a99312abf1..13235adf45 100644 --- a/Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/lldb/rmi/LldbConnectorsTest.java +++ b/Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/lldb/rmi/LldbConnectorsTest.java @@ -16,8 +16,8 @@ package agent.lldb.rmi; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.junit.Assume.assumeFalse; +import static org.junit.Assert.*; +import static org.junit.Assume.*; import java.nio.file.Path; import java.util.List; @@ -31,8 +31,7 @@ import db.Transaction; import generic.jar.ResourceFile; import ghidra.app.plugin.core.debug.gui.action.BySectionAutoMapSpec; import ghidra.app.plugin.core.debug.gui.tracermi.launcher.AbstractTraceRmiLaunchOffer.EarlyTerminationException; -import ghidra.app.util.importer.AutoImporter; -import ghidra.app.util.importer.MessageLog; +import ghidra.app.util.importer.ProgramLoader; import ghidra.debug.api.action.AutoMapSpec; import ghidra.debug.api.tracermi.TraceRmiLaunchOffer.LaunchResult; import ghidra.framework.Application; @@ -100,8 +99,11 @@ public class LldbConnectorsTest extends AbstractRmiConnectorsTest { public void testLldbQemuUser() throws Exception { assumeFalse(isWindows()); PathIsFile image = createArmElfImage(); - program = AutoImporter.importByUsingBestGuess(image.path().toFile(), null, "/", this, - new MessageLog(), monitor).getPrimaryDomainObject(); + program = ProgramLoader.builder() + .source(image.path().toFile()) + .monitor(monitor) + .load() + .getPrimaryDomainObject(this); programManager.openProgram(program); try (LaunchResult result = doLaunch("lldb + qemu", Map.ofEntries( Map.entry("arg:1", image), diff --git a/Ghidra/Test/IntegrationTest/src/screen/java/help/screenshot/ShowInstructionInfoPluginScreenShots.java b/Ghidra/Test/IntegrationTest/src/screen/java/help/screenshot/ShowInstructionInfoPluginScreenShots.java index db468bf58a..02eecd9449 100644 --- a/Ghidra/Test/IntegrationTest/src/screen/java/help/screenshot/ShowInstructionInfoPluginScreenShots.java +++ b/Ghidra/Test/IntegrationTest/src/screen/java/help/screenshot/ShowInstructionInfoPluginScreenShots.java @@ -16,6 +16,7 @@ package help.screenshot; import java.awt.*; +import java.net.URI; import java.net.URL; import javax.swing.JLabel; @@ -122,8 +123,8 @@ public class ShowInstructionInfoPluginScreenShots extends GhidraScreenShotGenera @Test public void testUnableToLaunch() throws Exception { - URL url1 = new URL("http://localhost:11046/1234567//pentium.pdf#page=701"); - URL url2 = new URL("file:/Ghidra/docs/manuals/pentium.pdf#page=701"); + URL url1 = new URI("http://localhost:11046/1234567//pentium.pdf#page=701").toURL(); + URL url2 = new URI("file:/Ghidra/docs/manuals/pentium.pdf#page=701").toURL(); final LaunchErrorDialog dialog = new LaunchErrorDialog(url1, url2); runSwing(() -> dialog.setVisible(true), false); diff --git a/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/app/util/headless/MyHeadlessToolkit.java b/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/app/util/headless/MyHeadlessToolkit.java index 00eb0295f6..8ba64639e4 100644 --- a/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/app/util/headless/MyHeadlessToolkit.java +++ b/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/app/util/headless/MyHeadlessToolkit.java @@ -92,7 +92,7 @@ public class MyHeadlessToolkit extends Toolkit { @Override public String[] getFontList() { - return localToolKit.getFontList(); + return GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); } @Override diff --git a/Ghidra/Test/IntegrationTest/src/test/java/docking/widgets/formatter/HexIntegerFormatterTest.java b/Ghidra/Test/IntegrationTest/src/test/java/docking/widgets/formatter/HexIntegerFormatterTest.java index 12199824c4..e2da6e9ab3 100644 --- a/Ghidra/Test/IntegrationTest/src/test/java/docking/widgets/formatter/HexIntegerFormatterTest.java +++ b/Ghidra/Test/IntegrationTest/src/test/java/docking/widgets/formatter/HexIntegerFormatterTest.java @@ -15,9 +15,8 @@ */ package docking.widgets.formatter; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.MatcherAssert.*; import java.text.ParseException;