Skip to content

Commit 5ec1696

Browse files
committed
Stop using deprecated ClassUtils#getLocation
There is now the Types#location method instead.
1 parent 184005b commit 5ec1696

File tree

10 files changed

+15
-15
lines changed

10 files changed

+15
-15
lines changed

src/main/java/org/scijava/Locatable.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
import java.net.URL;
3636

37-
import org.scijava.util.ClassUtils;
37+
import org.scijava.util.Types;
3838

3939
/**
4040
* An object whose location is defined by a URL string.
@@ -45,7 +45,7 @@ public interface Locatable {
4545

4646
/** Gets the URL string defining the object's location. */
4747
default String getLocation() {
48-
final URL location = ClassUtils.getLocation(getClass());
48+
final URL location = Types.location(getClass());
4949
return location == null ? null : location.toExternalForm();
5050
}
5151

src/main/java/org/scijava/menu/ShadowMenu.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ private String details(final ModuleInfo info) {
569569
try {
570570
final Class<?> c = info.loadDelegateClass();
571571
className = c.getName();
572-
classLocation = ClassUtils.getLocation(c).toString();
572+
classLocation = Types.location(c).toString();
573573
}
574574
catch (final ClassNotFoundException exc) {
575575
className = info.getDelegateClassName();

src/main/java/org/scijava/module/ModuleInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
import org.scijava.Versioned;
4343
import org.scijava.event.EventService;
4444
import org.scijava.module.event.ModulesUpdatedEvent;
45-
import org.scijava.util.ClassUtils;
45+
import org.scijava.util.Types;
4646
import org.scijava.util.VersionUtils;
4747

4848
/**
@@ -220,7 +220,7 @@ default String getLocation() {
220220
// If the same delegate class is used for more than one module, though,
221221
// it may need to override this method to indicate a different location.
222222
try {
223-
return ClassUtils.getLocation(loadDelegateClass()).toExternalForm();
223+
return Types.location(loadDelegateClass()).toExternalForm();
224224
}
225225
catch (final ClassNotFoundException exc) {
226226
return null;

src/main/java/org/scijava/plugin/PluginInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ public String getIdentifier() {
333333
@Override
334334
public String getLocation() {
335335
try {
336-
return ClassUtils.getLocation(loadClass()).toExternalForm();
336+
return Types.location(loadClass()).toExternalForm();
337337
}
338338
catch (InstantiableException exc) {
339339
return null;

src/main/java/org/scijava/script/ScriptLanguageIndex.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
import javax.script.ScriptEngineFactory;
4242

4343
import org.scijava.log.LogService;
44-
import org.scijava.util.ClassUtils;
4544
import org.scijava.util.FileUtils;
45+
import org.scijava.util.Types;
4646

4747
/**
4848
* Data structure for managing registered scripting languages.
@@ -184,6 +184,6 @@ private String overwriteMessage(final boolean overwrite, final String type,
184184
/** Helper method of {@link #overwriteMessage}. */
185185
private String details(final ScriptLanguage language) {
186186
final Class<?> c = language.getClass();
187-
return c.getName() + " [" + ClassUtils.getLocation(c);
187+
return c.getName() + " [" + Types.location(c);
188188
}
189189
}

src/main/java/org/scijava/test/TestUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
import java.util.AbstractMap;
3939
import java.util.Map;
4040

41-
import org.scijava.util.ClassUtils;
4241
import org.scijava.util.FileUtils;
42+
import org.scijava.util.Types;
4343

4444
/**
4545
* A bunch of helpful functions for unit tests.
@@ -128,7 +128,7 @@ public static File createTemporaryDirectory(final String prefix,
128128
public static File createTemporaryDirectory(final String prefix,
129129
final Class<?> forClass, final String suffix) throws IOException
130130
{
131-
final URL directory = ClassUtils.getLocation(forClass);
131+
final URL directory = Types.location(forClass);
132132
if (directory == null) {
133133
throw new IllegalArgumentException("No location for class " + forClass);
134134
}

src/main/java/org/scijava/util/AppUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public static File getBaseDirectory(final Class<?> c,
135135
// see: http://stackoverflow.com/a/12733172/1207769
136136

137137
// step 1: convert Class to URL
138-
final URL location = ClassUtils.getLocation(c);
138+
final URL location = Types.location(c);
139139

140140
// step 2: convert URL to File
141141
File baseFile;

src/main/java/org/scijava/util/Manifest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public Map<Object, Object> getAll() {
139139
/** Gets the JAR manifest associated with the given class. */
140140
public static Manifest getManifest(final Class<?> c) {
141141
try {
142-
return getManifest(new URL("jar:" + ClassUtils.getLocation(c) + "!/"));
142+
return getManifest(new URL("jar:" + Types.location(c) + "!/"));
143143
}
144144
catch (final IOException e) {
145145
return null;

src/main/java/org/scijava/util/POM.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public static POM getPOM(final Class<?> c, final String groupId,
227227
final String artifactId)
228228
{
229229
try {
230-
final URL location = ClassUtils.getLocation(c);
230+
final URL location = Types.location(c);
231231
if (!location.getProtocol().equals("file") ||
232232
location.toString().endsWith(".jar"))
233233
{

src/main/java/org/scijava/util/XML.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public XML(final String path, final Document doc) {
129129
// configured services, including the
130130
// com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl).
131131
if (debug) {
132-
System.err.println(ClassUtils.getLocation(XPathFactory.class));
132+
System.err.println(Types.location(XPathFactory.class));
133133
}
134134

135135
XPath xp = null;
@@ -147,7 +147,7 @@ public XML(final String path, final Document doc) {
147147
} catch (Throwable t) {
148148
if (debug) {
149149
System.err.println("There was a problem with " + xp.getClass() +
150-
" in " + ClassUtils.getLocation(xp.getClass()) + ":");
150+
" in " + Types.location(xp.getClass()) + ":");
151151
t.printStackTrace();
152152
}
153153
throw new Error(t);

0 commit comments

Comments
 (0)