Ghidra is a software reverse engineering (SRE) framework
GP-0: Fixing warnings in Utility project
Ryan Kurtz6cf47563fbfd
diff --git a/Ghidra/Framework/Utility/src/main/java/generic/jar/JarResource.java b/Ghidra/Framework/Utility/src/main/java/generic/jar/JarResource.javaindex b816f6750b..ff9d5e81a4 100644--- a/Ghidra/Framework/Utility/src/main/java/generic/jar/JarResource.java+++ b/Ghidra/Framework/Utility/src/main/java/generic/jar/JarResource.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,14 +15,13 @@*/package generic.jar;-import ghidra.util.Msg;-import ghidra.util.exception.AssertException;-import java.io.*;import java.net.*;import java.util.ArrayList;import java.util.List;+import ghidra.util.Msg;+import ghidra.util.exception.AssertException;import utilities.util.FileUtilities;import utility.application.ApplicationSettings;@@ -85,7 +84,12 @@ public class JarResource implements Resource {@Overridepublic URL toURL() throws MalformedURLException {- return new URL(getAbsolutePath());+ try {+ return new URI(getAbsolutePath()).toURL();+ }+ catch (URISyntaxException e) {+ throw new MalformedURLException(e.getMessage());+ }}@Overridediff --git a/Ghidra/Framework/Utility/src/main/java/ghidra/framework/plugintool/ServiceProvider.java b/Ghidra/Framework/Utility/src/main/java/ghidra/framework/plugintool/ServiceProvider.javaindex 309bec022f..8281d170d4 100644--- a/Ghidra/Framework/Utility/src/main/java/ghidra/framework/plugintool/ServiceProvider.java+++ b/Ghidra/Framework/Utility/src/main/java/ghidra/framework/plugintool/ServiceProvider.java@@ -1,13 +1,12 @@/* ###* IP: GHIDRA- * REVIEWED: YES** 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.@@ -23,8 +22,9 @@ import ghidra.framework.plugintool.util.ServiceListener;*/public interface ServiceProvider {/**- * Returns the Service object that implements the given service interface.+ * {@return the Service object that implements the given service interface.}* @param serviceClass the interface class.+ * @param <T> The type*/public <T> T getService(Class<T> serviceClass);@@ -39,7 +39,7 @@ public interface ServiceProvider {/*** Removes the given listener from this ServiceProvider. This method does nothing if the* given listener is not contained by this ServiceProvider.- * @param listener+ * @param listener The listener to remove*/public void removeServiceListener( ServiceListener listener );}diff --git a/Ghidra/Framework/Utility/src/main/java/ghidra/util/Fixup.java b/Ghidra/Framework/Utility/src/main/java/ghidra/util/Fixup.javaindex 2a830218ca..c15eb01db0 100644--- a/Ghidra/Framework/Utility/src/main/java/ghidra/util/Fixup.java+++ b/Ghidra/Framework/Utility/src/main/java/ghidra/util/Fixup.java@@ -1,13 +1,12 @@/* ###* IP: GHIDRA- * REVIEWED: YES** 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.@@ -29,9 +28,8 @@ public interface Fixup {public String getDescription();/**- * Return true if this Fixup object can automatically perform some action to address the issue. false- * if the fixup() method does nothing.- * @return+ * {@return true if this Fixup object can automatically perform some action to address the+ * issue. false if the fixup() method does nothing.}*/public boolean canFixup();diff --git a/Ghidra/Framework/Utility/src/main/java/ghidra/util/HashingOutputStream.java b/Ghidra/Framework/Utility/src/main/java/ghidra/util/HashingOutputStream.javaindex 453a94126c..a5d62eb792 100644--- a/Ghidra/Framework/Utility/src/main/java/ghidra/util/HashingOutputStream.java+++ b/Ghidra/Framework/Utility/src/main/java/ghidra/util/HashingOutputStream.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,32 +34,38 @@ public class HashingOutputStream extends OutputStream {/*** @param out - OutputStream to wrap* @param hashAlgo - see {@link MessageDigest#getInstance(String)}, ie. "MD5".- * @throws NoSuchAlgorithmException+ * @throws NoSuchAlgorithmException if no Provider supports a MessageDigestSpi implementation+ * for the specified algorithm*/public HashingOutputStream(OutputStream out, String hashAlgo) throws NoSuchAlgorithmException {this.out = out;this.messageDigest = MessageDigest.getInstance(hashAlgo);}+ @Overridepublic void write(int b) throws IOException {messageDigest.update((byte) (b & 0xff));out.write(b);}+ @Overridepublic void write(byte b[]) throws IOException {messageDigest.update(b);out.write(b, 0, b.length);}+ @Overridepublic void write(byte b[], int off, int len) throws IOException {messageDigest.update(b, off, len);out.write(b, off, len);}+ @Overridepublic void flush() throws IOException {out.flush();}+ @Overridepublic void close() throws IOException {try (OutputStream ostream = out) {ostream.flush();diff --git a/Ghidra/Framework/Utility/src/main/java/ghidra/util/NullOutputStream.java b/Ghidra/Framework/Utility/src/main/java/ghidra/util/NullOutputStream.javaindex 234ba2bb6f..af9b1a57d0 100644--- a/Ghidra/Framework/Utility/src/main/java/ghidra/util/NullOutputStream.java+++ b/Ghidra/Framework/Utility/src/main/java/ghidra/util/NullOutputStream.java@@ -26,22 +26,27 @@ public class NullOutputStream extends OutputStream {public NullOutputStream() {}+ @Overridepublic void write(int b) throws IOException {// nada}+ @Overridepublic void write(byte b[]) throws IOException {// nada}+ @Overridepublic void write(byte b[], int off, int len) throws IOException {// nada}+ @Overridepublic void flush() throws IOException {// nada}+ @Overridepublic void close() throws IOException {// nada}diff --git a/Ghidra/Framework/Utility/src/main/java/ghidra/xml/AbstractXmlPullParser.java b/Ghidra/Framework/Utility/src/main/java/ghidra/xml/AbstractXmlPullParser.javaindex a5967be545..78dbee369b 100644--- a/Ghidra/Framework/Utility/src/main/java/ghidra/xml/AbstractXmlPullParser.java+++ b/Ghidra/Framework/Utility/src/main/java/ghidra/xml/AbstractXmlPullParser.java@@ -1,13 +1,12 @@/* ###* IP: GHIDRA- * REVIEWED: YES** 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 +17,7 @@ package ghidra.xml;public abstract class AbstractXmlPullParser implements XmlPullParser {+ @Overridepublic XmlElement end() {if (!hasNext()) {throw new XmlException("at EOF but expected end element");@@ -30,6 +30,7 @@ public abstract class AbstractXmlPullParser implements XmlPullParser {return next;}+ @Overridepublic XmlElement end(XmlElement element) {String name = element.getName();if (!hasNext()) {@@ -47,6 +48,7 @@ public abstract class AbstractXmlPullParser implements XmlPullParser {return next;}+ @Overridepublic int getColumnNumber() {if (hasNext()) {return peek().getColumnNumber();@@ -54,6 +56,7 @@ public abstract class AbstractXmlPullParser implements XmlPullParser {return -1;}+ @Overridepublic int getCurrentLevel() {if (hasNext()) {return peek().getLevel();@@ -61,6 +64,7 @@ public abstract class AbstractXmlPullParser implements XmlPullParser {return -1;}+ @Overridepublic int getLineNumber() {if (hasNext()) {return peek().getLineNumber();@@ -86,6 +90,7 @@ public abstract class AbstractXmlPullParser implements XmlPullParser {return sb.toString();}+ @Overridepublic XmlElement start(String... names) {if (!hasNext()) {throw new XmlException("at EOF but expected start element " + collapse(names));@@ -109,6 +114,7 @@ public abstract class AbstractXmlPullParser implements XmlPullParser {return next;}+ @Overridepublic XmlElement softStart(String... names) {if (!hasNext()) {throw new XmlException("at EOF but expected soft start element " + collapse(names));@@ -130,10 +136,12 @@ public abstract class AbstractXmlPullParser implements XmlPullParser {return next();}+ @Overridepublic int discardSubTree() {return discardSubTree(peek());}+ @Overridepublic int discardSubTree(XmlElement element) {if (element == peek()) {// we're being asked to skip the entire subtree starting from the front of the queue@@ -193,6 +201,7 @@ public abstract class AbstractXmlPullParser implements XmlPullParser {}}+ @Overridepublic int discardSubTree(String elementName) {XmlElement start = start(elementName);return discardSubTree(start) + 1;