diff options
author | Julien Gouesse <[email protected]> | 2023-02-15 23:08:25 +0100 |
---|---|---|
committer | Julien Gouesse <[email protected]> | 2023-02-15 23:08:25 +0100 |
commit | aa6df077361bf1470d3799514f5774951025bed4 (patch) | |
tree | ef4161d363c026cfcdf9ac884f91a16bf09869ef | |
parent | d0444773304dd536898183e361d2737315aee6b5 (diff) |
Removes some deprecated calls in order to ease compilation with future versions of Java
18 files changed, 38 insertions, 125 deletions
diff --git a/ardor3d-audio/src/main/java/com/ardor3d/audio/SoundSystem.java b/ardor3d-audio/src/main/java/com/ardor3d/audio/SoundSystem.java index 8f09183..671fd5d 100644 --- a/ardor3d-audio/src/main/java/com/ardor3d/audio/SoundSystem.java +++ b/ardor3d-audio/src/main/java/com/ardor3d/audio/SoundSystem.java @@ -1526,21 +1526,9 @@ public class SoundSystem try { - soundLibrary = (Library) libraryClass.newInstance(); + soundLibrary = (Library) libraryClass.getDeclaredConstructor().newInstance(); } - catch( InstantiationException ie ) - { - errorMessage( "The specified library did not load properly", 1 ); - } - catch( IllegalAccessException iae ) - { - errorMessage( "The specified library did not load properly", 1 ); - } - catch( ExceptionInInitializerError eiie ) - { - errorMessage( "The specified library did not load properly", 1 ); - } - catch( SecurityException se ) + catch( Exception e ) { errorMessage( "The specified library did not load properly", 1 ); } diff --git a/ardor3d-audio/src/main/java/com/ardor3d/audio/SoundSystemConfig.java b/ardor3d-audio/src/main/java/com/ardor3d/audio/SoundSystemConfig.java index 546d71e..59b16c0 100644 --- a/ardor3d-audio/src/main/java/com/ardor3d/audio/SoundSystemConfig.java +++ b/ardor3d-audio/src/main/java/com/ardor3d/audio/SoundSystemConfig.java @@ -1039,24 +1039,9 @@ public class SoundSystemConfig Object o = null; try { - o = iCodecClass.newInstance(); + o = iCodecClass.getDeclaredConstructor().newInstance(); } - catch( InstantiationException ie ) - { - instantiationErrorMessage(); - return null; - } - catch( IllegalAccessException iae ) - { - instantiationErrorMessage(); - return null; - } - catch( ExceptionInInitializerError eiie ) - { - instantiationErrorMessage(); - return null; - } - catch( SecurityException se ) + catch( Exception e ) { instantiationErrorMessage(); return null; diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/state/FragmentProgramState.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/state/FragmentProgramState.java index 3a3083c..1bbf316 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/renderer/state/FragmentProgramState.java +++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/state/FragmentProgramState.java @@ -105,9 +105,6 @@ public class FragmentProgramState extends RenderState { // Set data with byte content from stream final byte data[] = outputStream.toByteArray(); - // Release resources - inputStream.close(); - program = BufferUtils.createByteBuffer(data.length); program.put(data); program.rewind(); diff --git a/ardor3d-core/src/main/java/com/ardor3d/renderer/state/GLSLShaderObjectsState.java b/ardor3d-core/src/main/java/com/ardor3d/renderer/state/GLSLShaderObjectsState.java index 77a2936..8a98868 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/renderer/state/GLSLShaderObjectsState.java +++ b/ardor3d-core/src/main/java/com/ardor3d/renderer/state/GLSLShaderObjectsState.java @@ -1324,15 +1324,12 @@ public class GLSLShaderObjectsState extends RenderState { } try { - final T shaderUniform = classz.newInstance(); + final T shaderUniform = classz.getDeclaredConstructor().newInstance(); shaderUniform.name = name; shaderVariableList.add(shaderUniform); return shaderUniform; - } catch (final InstantiationException e) { - logger.logp(Level.SEVERE, this.getClass().toString(), "getShaderVariable(name, classz, shaderVariableList)", - "Exception", e); - } catch (final IllegalAccessException e) { + } catch (final Exception e) { logger.logp(Level.SEVERE, this.getClass().toString(), "getShaderVariable(name, classz, shaderVariableList)", "Exception", e); } diff --git a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Spatial.java b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Spatial.java index 0b3f5ce..9c00d53 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Spatial.java +++ b/ardor3d-core/src/main/java/com/ardor3d/scenegraph/Spatial.java @@ -1288,7 +1288,7 @@ public abstract class Spatial implements Savable, Hintable { try { final SavableFactory ann = clazz.getAnnotation(SavableFactory.class); if (ann == null) { - spat = clazz.newInstance(); + spat = clazz.getDeclaredConstructor().newInstance(); } else { spat = (Spatial) clazz.getMethod(ann.factoryMethod(), (Class<?>[]) null).invoke(null, (Object[]) null); } diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/Constants.java b/ardor3d-core/src/main/java/com/ardor3d/util/Constants.java index 71210ac..1c2e0ca 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/util/Constants.java +++ b/ardor3d-core/src/main/java/com/ardor3d/util/Constants.java @@ -17,52 +17,19 @@ public class Constants { public static boolean updateGraphs = false; - public static final boolean useStatePools; + public static final boolean useStatePools = System.getProperty("ardor3d.noStatePools") == null; - public static final boolean stats; + public static final boolean stats = System.getProperty("ardor3d.stats") != null; - public static final boolean trackDirectMemory; + public static final boolean trackDirectMemory = System.getProperty("ardor3d.trackDirect") != null; - public static final boolean useMultipleContexts; + public static final boolean useMultipleContexts = System.getProperty("ardor3d.useMultipleContexts") != null; - public static final boolean storeSavableImages; + public static final boolean storeSavableImages = System.getProperty("ardor3d.storeSavableImages") != null; - public static final int maxStatePoolSize; + public static final int maxStatePoolSize = Integer.parseInt(System.getProperty("ardor3d.maxStatePoolSize", "11")); - public static final boolean useValidatingTransform; + public static final boolean useValidatingTransform = System.getProperty("ardor3d.disableValidatingTransform") == null; - public static final boolean enableInstancedGeometrySupport; - - static { - boolean hasPropertyAccess = true; - try { - if (System.getSecurityManager() != null) { - System.getSecurityManager().checkPropertiesAccess(); - } - } catch (final SecurityException e) { - hasPropertyAccess = false; - } - - if (hasPropertyAccess) { - stats = (System.getProperty("ardor3d.stats") != null); - trackDirectMemory = (System.getProperty("ardor3d.trackDirect") != null); - useMultipleContexts = (System.getProperty("ardor3d.useMultipleContexts") != null); - useStatePools = (System.getProperty("ardor3d.noStatePools") == null); - storeSavableImages = (System.getProperty("ardor3d.storeSavableImages") != null); - maxStatePoolSize = (System.getProperty("ardor3d.maxStatePoolSize") != null ? Integer.parseInt(System - .getProperty("ardor3d.maxStatePoolSize")) : 11); - - useValidatingTransform = (System.getProperty("ardor3d.disableValidatingTransform") == null); - enableInstancedGeometrySupport = (System.getProperty("ardor3d.enableInstancedGeometrySupport") != null); - } else { - stats = false; - trackDirectMemory = false; - useMultipleContexts = false; - useStatePools = true; - storeSavableImages = false; - maxStatePoolSize = 11; - useValidatingTransform = true; - enableInstancedGeometrySupport = false; - } - } + public static final boolean enableInstancedGeometrySupport = System.getProperty("ardor3d.enableInstancedGeometrySupport") != null; } diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryImporter.java b/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryImporter.java index f77c220..3e90b96 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryImporter.java +++ b/ardor3d-core/src/main/java/com/ardor3d/util/export/binary/BinaryImporter.java @@ -236,7 +236,7 @@ public class BinaryImporter implements Ardor3dImporter { final Class<? extends Savable> clazz = (Class<? extends Savable>) Class.forName(bco._className); final SavableFactory ann = clazz.getAnnotation(SavableFactory.class); if (ann == null) { - out = clazz.newInstance(); + out = clazz.getDeclaredConstructor().newInstance(); } else { out = (Savable) clazz.getMethod(ann.factoryMethod(), (Class<?>[]) null).invoke(null, (Object[]) null); diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMInputCapsule.java b/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMInputCapsule.java index 0cbeea8..9905b06 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMInputCapsule.java +++ b/ardor3d-core/src/main/java/com/ardor3d/util/export/xml/DOMInputCapsule.java @@ -820,7 +820,7 @@ public class DOMInputCapsule implements InputCapsule { final Class<? extends Savable> clazz = (Class<? extends Savable>) Class.forName(className); final SavableFactory ann = clazz.getAnnotation(SavableFactory.class); if (ann == null) { - tmp = clazz.newInstance(); + tmp = clazz.getDeclaredConstructor().newInstance(); } else { tmp = (Savable) clazz.getMethod(ann.factoryMethod(), (Class<?>[]) null).invoke(null, (Object[]) null); diff --git a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/water/ProjectedGrid.java b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/water/ProjectedGrid.java index 54a0c17..b9e26b7 100644 --- a/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/water/ProjectedGrid.java +++ b/ardor3d-effects/src/main/java/com/ardor3d/extension/effect/water/ProjectedGrid.java @@ -631,8 +631,7 @@ public class ProjectedGrid extends Mesh { final String namePrefix; DeamonThreadFactory() { - final SecurityManager s = System.getSecurityManager(); - group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup(); + group = Thread.currentThread().getThreadGroup(); namePrefix = "ProjectedGrid Pool-" + poolNumber.getAndIncrement() + "-thread-"; } diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/ExampleBase.java b/ardor3d-examples/src/main/java/com/ardor3d/example/ExampleBase.java index 385e1a2..bc5fc45 100644 --- a/ardor3d-examples/src/main/java/com/ardor3d/example/ExampleBase.java +++ b/ardor3d-examples/src/main/java/com/ardor3d/example/ExampleBase.java @@ -352,7 +352,7 @@ public abstract class ExampleBase implements Runnable, Updater, Scene { public static void start(final Class<? extends ExampleBase> exampleClazz) { ExampleBase example; try { - example = exampleClazz.newInstance(); + example = exampleClazz.getDeclaredConstructor().newInstance(); } catch (final Exception ex) { ex.printStackTrace(); return; diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/craft/examples/thegame/RealGame.java b/ardor3d-examples/src/main/java/com/ardor3d/example/craft/examples/thegame/RealGame.java index fb72e19..41a0bb5 100644 --- a/ardor3d-examples/src/main/java/com/ardor3d/example/craft/examples/thegame/RealGame.java +++ b/ardor3d-examples/src/main/java/com/ardor3d/example/craft/examples/thegame/RealGame.java @@ -165,7 +165,7 @@ public class RealGame implements ArdorCraftGame { DataGenerator dataGenerator = null; try { - dataGenerator = (DataGenerator) dialog.getSelectedGenerator().newInstance(); + dataGenerator = (DataGenerator) dialog.getSelectedGenerator().getDeclaredConstructor().newInstance(); } catch (final Exception e) { e.printStackTrace(); } diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/craft/generators/GeneratorViewer.java b/ardor3d-examples/src/main/java/com/ardor3d/example/craft/generators/GeneratorViewer.java index 35784df..6202b69 100644 --- a/ardor3d-examples/src/main/java/com/ardor3d/example/craft/generators/GeneratorViewer.java +++ b/ardor3d-examples/src/main/java/com/ardor3d/example/craft/generators/GeneratorViewer.java @@ -314,8 +314,7 @@ public class GeneratorViewer { final String namePrefix; DeamonThreadFactory() { - final SecurityManager s = System.getSecurityManager(); - group = s != null ? s.getThreadGroup() : Thread.currentThread().getThreadGroup(); + group = Thread.currentThread().getThreadGroup(); namePrefix = "Worker Pool-" + poolNumber.getAndIncrement() + "-thread-"; } diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/MathConstants.java b/ardor3d-math/src/main/java/com/ardor3d/math/MathConstants.java index e03e1f6..2204fd2 100644 --- a/ardor3d-math/src/main/java/com/ardor3d/math/MathConstants.java +++ b/ardor3d-math/src/main/java/com/ardor3d/math/MathConstants.java @@ -15,42 +15,16 @@ package com.ardor3d.math; */ public class MathConstants { - public static final boolean useMathPools; + public static final boolean useMathPools = System.getProperty("ardor3d.noMathPools") == null; - public static final boolean useFastMath; + public static final boolean useFastMath = System.getProperty("ardor3d.useFastMath") != null; - public static final int maxMathPoolSize; + public static final int maxMathPoolSize = Integer.parseInt(System.getProperty("ardor3d.maxMathPoolSize", "11")); /** * Flag indicating whether zero floating-point representations's sign is taken into account when comparing values. * <code>true</code> when -0.0 and 0.0 are considered equal, otherwise <code>false</code>. Ignoring the sign * produces a numerically correct behavior but is inconsistent with java.lang.Double.compare() */ - public static final boolean ignoreZeroFloatingPointRepresentationSign; - - static { - boolean hasPropertyAccess = true; - try { - if (System.getSecurityManager() != null) { - System.getSecurityManager().checkPropertiesAccess(); - } - } catch (final SecurityException e) { - hasPropertyAccess = false; - } - - if (hasPropertyAccess) { - useMathPools = (System.getProperty("ardor3d.noMathPools") == null); - useFastMath = (System.getProperty("ardor3d.useFastMath") != null); - maxMathPoolSize = (System.getProperty("ardor3d.maxMathPoolSize") != null - ? Integer.parseInt(System.getProperty("ardor3d.maxMathPoolSize")) - : 11); - ignoreZeroFloatingPointRepresentationSign = (System - .getProperty("ardor3d.useZeroFloatingPointRepresentationSign") == null); - } else { - useMathPools = true; - useFastMath = false; - maxMathPoolSize = 11; - ignoreZeroFloatingPointRepresentationSign = true; - } - } + public static final boolean ignoreZeroFloatingPointRepresentationSign = System.getProperty("ardor3d.useZeroFloatingPointRepresentationSign") == null; } diff --git a/ardor3d-math/src/main/java/com/ardor3d/math/ObjectPool.java b/ardor3d-math/src/main/java/com/ardor3d/math/ObjectPool.java index 53fcf1c..5594e4b 100644 --- a/ardor3d-math/src/main/java/com/ardor3d/math/ObjectPool.java +++ b/ardor3d-math/src/main/java/com/ardor3d/math/ObjectPool.java @@ -57,7 +57,7 @@ public abstract class ObjectPool<T extends Poolable> { @Override protected T newInstance() { try { - return clazz.newInstance(); + return clazz.getDeclaredConstructor().newInstance(); } catch (final Exception e) { throw new RuntimeException(e); } diff --git a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/Terrain.java b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/Terrain.java index 229886c..bb6e8e7 100644 --- a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/Terrain.java +++ b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/client/Terrain.java @@ -11,6 +11,7 @@ package com.ardor3d.extension.terrain.client; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import java.net.URL; import java.nio.FloatBuffer; import java.util.ArrayList; @@ -538,7 +539,7 @@ public class Terrain extends Node implements Pickable { } public void makePickable(final Class<? extends AbstractBresenhamTracer> tracerClass, final int maxChecks, - final Vector3 initialSpacing) throws InstantiationException, IllegalAccessException { + final Vector3 initialSpacing) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { // init the terrain picker _picker = new ClipmapTerrainPicker(_clips, tracerClass, maxChecks, initialSpacing); } diff --git a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/util/ClipmapTerrainPicker.java b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/util/ClipmapTerrainPicker.java index b0e06d8..6a13927 100644 --- a/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/util/ClipmapTerrainPicker.java +++ b/ardor3d-terrain/src/main/java/com/ardor3d/extension/terrain/util/ClipmapTerrainPicker.java @@ -10,6 +10,7 @@ package com.ardor3d.extension.terrain.util; +import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.List; @@ -54,14 +55,18 @@ public class ClipmapTerrainPicker { * if we are unable to create an instance of our tracerClass * @throws InstantiationException * if we are unable to create an instance of our tracerClass + * @throws InvocationTargetException + * if we are unable to create an instance of our tracerClass + * @throws NoSuchMethodException + * if we are unable to create an instance of our tracerClass */ public ClipmapTerrainPicker(final List<ClipmapLevel> levels, final Class<? extends AbstractBresenhamTracer> tracerClass, final int maxChecks, - final Vector3 initialSpacing) throws InstantiationException, IllegalAccessException { + final Vector3 initialSpacing) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { _clipmapLevels = levels; _tracers = new ArrayList<>(); for (int i = 0, max = levels.size(); i < max; i++) { - final AbstractBresenhamTracer tracer = tracerClass.newInstance(); + final AbstractBresenhamTracer tracer = tracerClass.getDeclaredConstructor().newInstance(); final int space = 1 << i; final Vector3 vec = new Vector3(initialSpacing).multiplyLocal(space); if (vec.getX() == 0) { diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/CopyPasteManager.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/CopyPasteManager.java index 2ac0bb1..31cbe81 100644 --- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/CopyPasteManager.java +++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/text/CopyPasteManager.java @@ -25,7 +25,7 @@ public enum CopyPasteManager { public String getClipBoardContents() { if (_impl == null) { try { - _impl = (CopyPasteImpl) Class.forName("com.ardor3d.ui.text.awt.AwtCopyPasteImpl").newInstance(); + _impl = (CopyPasteImpl) Class.forName("com.ardor3d.ui.text.awt.AwtCopyPasteImpl").getDeclaredConstructor().newInstance(); } catch (final Throwable t) { _impl = new NullCopyPasteImpl(); } @@ -36,7 +36,7 @@ public enum CopyPasteManager { public void setClipBoardContents(final String contents) { if (_impl == null) { try { - _impl = (CopyPasteImpl) Class.forName("com.ardor3d.ui.text.awt.AwtCopyPasteImpl").newInstance(); + _impl = (CopyPasteImpl) Class.forName("com.ardor3d.ui.text.awt.AwtCopyPasteImpl").getDeclaredConstructor().newInstance(); } catch (final Throwable t) { _impl = new NullCopyPasteImpl(); } diff --git a/build.gradle b/build.gradle index 39be1ff..517a67a 100644 --- a/build.gradle +++ b/build.gradle @@ -12,6 +12,7 @@ subprojects { tasks.withType(JavaCompile) { options.encoding = 'UTF-8' + options.compilerArgs = ['-Xlint:deprecation'] } task packageSources(type: Jar) { |