Skip to content

Commit afd4fa6

Browse files
authored
Fix many warnings during build (#2698)
* Fix javac warnings in core and plugins * Fix Gradle DSL deprecation warnings * Reduce Android deprecation warnings * Replace deprecated Mockito matcher import
1 parent 530c865 commit afd4fa6

31 files changed

Lines changed: 172 additions & 139 deletions

File tree

common.gradle

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ apply plugin: 'org.jmonkeyengine.nativeimage'
2828

2929
tasks.withType(JavaCompile) { // compile-time options:
3030
//options.compilerArgs << '-Xlint:deprecation' // to show deprecation warnings
31-
options.compilerArgs << '-Xlint:unchecked'
31+
options.compilerArgs.addAll(['-Xlint:unchecked', '-Xlint:-options', '-Werror'])
3232
options.encoding = 'UTF-8'
3333
options.release = 8
3434
}
@@ -103,26 +103,26 @@ task javadocJar(type: Jar, dependsOn: javadoc, description: 'Creates a jar from
103103
}
104104

105105
ext.pomConfig = {
106-
name POM_NAME
107-
description POM_DESCRIPTION
108-
url POM_URL
109-
inceptionYear POM_INCEPTION_YEAR
106+
name = POM_NAME
107+
description = POM_DESCRIPTION
108+
url = POM_URL
109+
inceptionYear = POM_INCEPTION_YEAR
110110
scm {
111-
url POM_SCM_URL
112-
connection POM_SCM_CONNECTION
113-
developerConnection POM_SCM_DEVELOPER_CONNECTION
111+
url = POM_SCM_URL
112+
connection = POM_SCM_CONNECTION
113+
developerConnection = POM_SCM_DEVELOPER_CONNECTION
114114
}
115115
licenses {
116116
license {
117-
name POM_LICENSE_NAME
118-
url POM_LICENSE_URL
119-
distribution POM_LICENSE_DISTRIBUTION
117+
name = POM_LICENSE_NAME
118+
url = POM_LICENSE_URL
119+
distribution = POM_LICENSE_DISTRIBUTION
120120
}
121121
}
122122
developers {
123123
developer {
124-
name 'jMonkeyEngine Team'
125-
id 'jMonkeyEngine'
124+
name = 'jMonkeyEngine Team'
125+
id = 'jMonkeyEngine'
126126
}
127127
}
128128
}

jme3-android/src/main/java/com/jme3/system/android/JmeAndroidSystem.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public void writeImageFile(OutputStream outStream, String format, ByteBuffer ima
7878

7979

8080
@Override
81+
@SuppressWarnings("deprecation")
8182
public JmeContext newContext(AppSettings settings, Type contextType) {
8283
if (settings.getAudioRenderer() == null) {
8384
audioRendererType = null;

jme3-android/src/main/java/com/jme3/system/android/OGLESContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,8 +727,8 @@ public void requestDialog(
727727
public void run() {
728728
final FrameLayout layoutTextDialogInput = new FrameLayout(view.getContext());
729729
final EditText editTextDialogInput = new EditText(view.getContext());
730-
editTextDialogInput.setWidth(LayoutParams.FILL_PARENT);
731-
editTextDialogInput.setHeight(LayoutParams.FILL_PARENT);
730+
editTextDialogInput.setWidth(LayoutParams.MATCH_PARENT);
731+
editTextDialogInput.setHeight(LayoutParams.MATCH_PARENT);
732732
editTextDialogInput.setPadding(20, 20, 20, 20);
733733
editTextDialogInput.setGravity(Gravity.FILL_HORIZONTAL);
734734
//editTextDialogInput.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);

jme3-core/src/main/java/com/jme3/effect/ParticleEmitter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ public ParticleEmitter clone(boolean cloneMaterial) {
187187
* The old clone() method that did not use the new Cloner utility.
188188
*/
189189
@Override
190+
@Deprecated
190191
public ParticleEmitter oldClone(boolean cloneMaterial) {
191192
ParticleEmitter clone = (ParticleEmitter) super.clone(cloneMaterial);
192193
clone.shape = shape.deepClone();

jme3-core/src/main/java/com/jme3/environment/EnvironmentCamera.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ protected void initialize(Application app) {
309309
viewports[i] = createOffViewPort("EnvView" + i, cameras[i]);
310310
framebuffers[i] = createOffScreenFrameBuffer(size, viewports[i]);
311311
textures[i] = new Texture2D(size, size, colorFormat);
312-
framebuffers[i].setColorTexture(textures[i]);
312+
framebuffers[i].addColorTarget(FrameBuffer.FrameBufferTarget.newTarget(textures[i]));
313313
}
314314
}
315315

@@ -416,7 +416,7 @@ protected FrameBuffer createOffScreenFrameBuffer(int mapSize, ViewPort offView)
416416
protected FrameBuffer createOffScreenFrameBuffer(int mapSize, ViewPort offView, Image.Format depthFormat) {
417417
// create offscreen framebuffer
418418
final FrameBuffer offBuffer = new FrameBuffer(mapSize, mapSize, 1);
419-
offBuffer.setDepthBuffer(depthFormat);
419+
offBuffer.setDepthTarget(FrameBuffer.FrameBufferTarget.newTarget(depthFormat));
420420
offView.setOutputFrameBuffer(offBuffer);
421421
return offBuffer;
422422
}

jme3-core/src/main/java/com/jme3/environment/EnvironmentProbeControl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ public static void untagGlobal(Spatial s) {
186186
}
187187

188188
@Override
189+
@Deprecated
189190
public Control cloneForSpatial(Spatial spatial) {
190191
throw new UnsupportedOperationException();
191192
}

jme3-core/src/main/java/com/jme3/renderer/Caps.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ public static boolean supports(Collection<Caps> caps, FrameBuffer fb) {
654654
return false;
655655
}
656656

657-
RenderBuffer depthBuf = fb.getDepthBuffer();
657+
RenderBuffer depthBuf = fb.getDepthTarget();
658658
if (depthBuf != null) {
659659
Format depthFmt = depthBuf.getFormat();
660660
if (!depthFmt.isDepthFormat()) {
@@ -681,8 +681,8 @@ public static boolean supports(Collection<Caps> caps, FrameBuffer fb) {
681681
}
682682
}
683683
}
684-
for (int i = 0; i < fb.getNumColorBuffers(); i++) {
685-
if (!supportsColorBuffer(caps, fb.getColorBuffer(i))) {
684+
for (int i = 0; i < fb.getNumColorTargets(); i++) {
685+
if (!supportsColorBuffer(caps, fb.getColorTarget(i))) {
686686
return false;
687687
}
688688
}

jme3-core/src/main/java/com/jme3/renderer/RenderContext.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,21 @@
3535
import com.jme3.math.ColorRGBA;
3636
import com.jme3.scene.VertexBuffer;
3737
import com.jme3.shader.Shader;
38+
import com.jme3.shader.bufferobject.BufferObject;
3839
import com.jme3.texture.FrameBuffer;
3940
import com.jme3.texture.Image;
4041
import java.lang.ref.WeakReference;
41-
import com.jme3.shader.bufferobject.BufferObject;
4242

4343
/**
4444
* Represents the current state of the graphics library. This class is used
4545
* internally to reduce state changes. NOTE: This class is specific to OpenGL.
4646
*/
4747
public class RenderContext {
48+
@SuppressWarnings("unchecked")
49+
private static <T> WeakReference<T>[] newWeakReferenceArray(int size) {
50+
return (WeakReference<T>[]) new WeakReference<?>[size];
51+
}
52+
4853
/**
4954
* Number of texture units that JME supports.
5055
*/
@@ -264,8 +269,8 @@ public class RenderContext {
264269
*
265270
* @see Renderer#setTexture(int, com.jme3.texture.Texture)
266271
*/
267-
public final WeakReference<Image> boundTextures[]
268-
= new WeakReference[maxTextureUnits];
272+
public final WeakReference<Image>[] boundTextures
273+
= newWeakReferenceArray(maxTextureUnits);
269274

270275

271276
/**
@@ -274,7 +279,7 @@ public class RenderContext {
274279
* @see Renderer#setUniformBufferObject(int, com.jme3.shader.BufferObject)
275280
* @see Renderer#setShaderStorageBufferObject(int, com.jme3.shader.BufferObject)
276281
*/
277-
public final WeakReference<BufferObject>[] boundBO = new WeakReference[maxBufferObjectUnits];
282+
public final WeakReference<BufferObject>[] boundBO = newWeakReferenceArray(maxBufferObjectUnits);
278283

279284
/**
280285
* IDList for texture units.
@@ -331,7 +336,7 @@ public class RenderContext {
331336
* Vertex attribs currently bound and enabled. If a slot is null, then
332337
* it is disabled.
333338
*/
334-
public final WeakReference<VertexBuffer>[] boundAttribs = new WeakReference[16];
339+
public final WeakReference<VertexBuffer>[] boundAttribs = newWeakReferenceArray(16);
335340

336341
/**
337342
* IDList for vertex attributes.

jme3-core/src/main/java/com/jme3/renderer/RenderManager.java

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,9 @@
3131
*/
3232
package com.jme3.renderer;
3333

34-
import com.jme3.renderer.pipeline.ForwardPipeline;
35-
import com.jme3.renderer.pipeline.DefaultPipelineContext;
36-
import com.jme3.renderer.pipeline.RenderPipeline;
37-
import com.jme3.renderer.pipeline.PipelineContext;
38-
import com.jme3.light.DefaultLightFilter;
39-
import com.jme3.light.LightFilter;
40-
import com.jme3.light.LightList;
34+
import com.jme3.light.DefaultLightFilter;
35+
import com.jme3.light.LightFilter;
36+
import com.jme3.light.LightList;
4137
import com.jme3.material.MatParamOverride;
4238
import com.jme3.material.Material;
4339
import com.jme3.material.MaterialDef;
@@ -46,11 +42,15 @@
4642
import com.jme3.material.TechniqueDef;
4743
import com.jme3.math.FastMath;
4844
import com.jme3.math.Matrix4f;
49-
import com.jme3.post.SceneProcessor;
50-
import com.jme3.profile.AppProfiler;
51-
import com.jme3.profile.AppStep;
52-
import com.jme3.profile.VpStep;
53-
import com.jme3.renderer.queue.GeometryList;
45+
import com.jme3.post.SceneProcessor;
46+
import com.jme3.profile.AppProfiler;
47+
import com.jme3.profile.AppStep;
48+
import com.jme3.profile.VpStep;
49+
import com.jme3.renderer.pipeline.DefaultPipelineContext;
50+
import com.jme3.renderer.pipeline.ForwardPipeline;
51+
import com.jme3.renderer.pipeline.PipelineContext;
52+
import com.jme3.renderer.pipeline.RenderPipeline;
53+
import com.jme3.renderer.queue.GeometryList;
5454
import com.jme3.renderer.queue.RenderQueue;
5555
import com.jme3.renderer.queue.RenderQueue.Bucket;
5656
import com.jme3.renderer.queue.RenderQueue.ShadowMode;
@@ -111,7 +111,7 @@ public class RenderManager {
111111
private final HashMap<Class<? extends PipelineContext>, PipelineContext> contexts = new HashMap<>();
112112
private final LinkedList<PipelineContext> usedContexts = new LinkedList<>();
113113
private final LinkedList<RenderPipeline<? extends PipelineContext>> usedPipelines = new LinkedList<>();
114-
private RenderPipeline<? extends PipelineContext> defaultPipeline = new ForwardPipeline();
114+
private RenderPipeline<? extends PipelineContext> defaultPipeline = new ForwardPipeline();
115115
private Camera prevCam = null;
116116
private Material forcedMaterial = null;
117117
private String forcedTechnique = null;
@@ -1382,19 +1382,22 @@ public void applyViewPort(ViewPort vp) {
13821382
* @param vp View port to render
13831383
* @param tpf Time per frame value
13841384
*/
1385-
public void renderViewPort(ViewPort vp, float tpf) {
1386-
if (!vp.isEnabled()) {
1387-
return;
1388-
}
1389-
RenderPipeline pipeline = vp.getPipeline();
1390-
if (pipeline == null) {
1391-
pipeline = defaultPipeline;
1392-
}
1393-
1394-
PipelineContext context = pipeline.fetchPipelineContext(this);
1395-
if (context == null) {
1396-
throw new NullPointerException("Failed to fetch pipeline context.");
1397-
}
1385+
public void renderViewPort(ViewPort vp, float tpf) {
1386+
if (!vp.isEnabled()) {
1387+
return;
1388+
}
1389+
RenderPipeline<? extends PipelineContext> pipeline = vp.getPipeline();
1390+
if (pipeline == null) {
1391+
pipeline = defaultPipeline;
1392+
}
1393+
renderViewPort(vp, tpf, pipeline);
1394+
}
1395+
1396+
private <T extends PipelineContext> void renderViewPort(ViewPort vp, float tpf, RenderPipeline<T> pipeline) {
1397+
T context = pipeline.fetchPipelineContext(this);
1398+
if (context == null) {
1399+
throw new NullPointerException("Failed to fetch pipeline context.");
1400+
}
13981401
if (!context.startViewPortRender(this, vp)) {
13991402
usedContexts.add(context);
14001403
}

jme3-core/src/main/java/com/jme3/renderer/ViewPort.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@
3131
*/
3232
package com.jme3.renderer;
3333

34-
import com.jme3.renderer.pipeline.RenderPipeline;
3534
import com.jme3.math.ColorRGBA;
3635
import com.jme3.post.SceneProcessor;
36+
import com.jme3.renderer.pipeline.PipelineContext;
37+
import com.jme3.renderer.pipeline.RenderPipeline;
3738
import com.jme3.renderer.queue.RenderQueue;
3839
import com.jme3.scene.Geometry;
3940
import com.jme3.scene.Spatial;
@@ -88,7 +89,7 @@ public class ViewPort {
8889
/**
8990
* Dedicated pipeline.
9091
*/
91-
protected RenderPipeline pipeline;
92+
protected RenderPipeline<? extends PipelineContext> pipeline;
9293
/**
9394
* FrameBuffer for output.
9495
*/
@@ -440,7 +441,7 @@ public boolean isEnabled() {
440441
*
441442
* @param pipeline pipeline, or null to use render manager's pipeline
442443
*/
443-
public void setPipeline(RenderPipeline pipeline) {
444+
public void setPipeline(RenderPipeline<? extends PipelineContext> pipeline) {
444445
this.pipeline = pipeline;
445446
}
446447

@@ -449,7 +450,7 @@ public void setPipeline(RenderPipeline pipeline) {
449450
*
450451
* @return
451452
*/
452-
public RenderPipeline getPipeline() {
453+
public RenderPipeline<? extends PipelineContext> getPipeline() {
453454
return pipeline;
454455
}
455456

0 commit comments

Comments
 (0)