Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/scripts/generate-quality-report.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,7 @@ def main() -> None:
"FE_FLOATING_POINT_EQUALITY",
"FE_TEST_IF_EQUAL_TO_NOT_A_NUMBER",
"ICAST_IDIV_CAST_TO_DOUBLE",
"ICAST_QUESTIONABLE_UNSIGNED_RIGHT_SHIFT",
"SA_FIELD_SELF_ASSIGNMENT",
"UC_USELESS_CONDITION",
"UC_USELESS_OBJECT",
Expand Down Expand Up @@ -824,6 +825,7 @@ def main() -> None:
"NP_LOAD_OF_KNOWN_NULL_VALUE",
"NP_BOOLEAN_RETURN_NULL",
"RC_REF_COMPARISON_BAD_PRACTICE_BOOLEAN",
"OS_OPEN_STREAM",
"REFLC_REFLECTION_MAY_INCREASE_ACCESSIBILITY_OF_CLASS",
"REC_CATCH_EXCEPTION",
"RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE",
Expand Down Expand Up @@ -865,6 +867,8 @@ def _is_exempt(f: Finding) -> bool:
return True
if f.rule == "NN_NAKED_NOTIFY" and "Display.java" in loc:
return True
if f.rule == "ICAST_QUESTIONABLE_UNSIGNED_RIGHT_SHIFT" and "Deflate.java" in loc:
return True
return False


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3966,22 +3966,19 @@ public Rectangle getDisplaySafeArea(Rectangle rect) {
* common constants in this class or be a user/implementation defined sound
*/
public void playBuiltinSound(String soundIdentifier) {
boolean played = playUserSound(soundIdentifier);
if (!played) {
return;
}
playUserSound(soundIdentifier);
}

/**
* Plays a sound defined by the user
*
* @param soundIdentifier the sound identifier which can match one of the
* common constants in this class or be a user/implementation defined sound
* @return true if a user sound exists and was sent to playback
*/
protected boolean playUserSound(String soundIdentifier) {
Object sound = builtinSounds.get(soundIdentifier);
return sound != null;
protected void playUserSound(String soundIdentifier) {
// TODO: Reintroduce builitin sound support
//Object sound = builtinSounds.get(soundIdentifier);
//return sound != null;
//playAudio(sound);
}

Expand Down
10 changes: 8 additions & 2 deletions CodenameOne/src/com/codename1/impl/CodenameOneThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
package com.codename1.impl;

import com.codename1.io.Log;
import com.codename1.io.Util;
import com.codename1.ui.Display;

import java.io.DataInputStream;
Expand Down Expand Up @@ -133,6 +134,8 @@ public void storeStackForException(Throwable t, int currentStackFrame) {
* Prints the stack trace matching the given stack
*/
public String getStack(Throwable t) {
InputStream inp = null;
DataInputStream di = null;
try {
StringBuilder b = new StringBuilder();
int size;
Expand All @@ -145,11 +148,11 @@ public String getStack(Throwable t) {
}
String[] stk = new String[size];

InputStream inp = Display.getInstance().getResourceAsStream(getClass(), "/methodData.dat");
inp = Display.getInstance().getResourceAsStream(getClass(), "/methodData.dat");
if (inp == null) {
return t.toString();
}
DataInputStream di = new DataInputStream(inp);
di = new DataInputStream(inp);
int totalAmount = di.readInt();
String lastClass = "";
for (int x = 0; x < totalAmount; x++) {
Expand All @@ -172,6 +175,9 @@ public String getStack(Throwable t) {
return b.toString();
} catch (IOException ex) {
ex.printStackTrace();
} finally {
Util.cleanup(di);
Util.cleanup(inp);
}
return "Failed in stack generation for " + t;
}
Expand Down
16 changes: 11 additions & 5 deletions CodenameOne/src/com/codename1/testing/DeviceRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
package com.codename1.testing;

import com.codename1.io.Log;
import com.codename1.io.Util;
import com.codename1.ui.CN;
import com.codename1.ui.Display;

Expand All @@ -48,8 +49,10 @@ public void runTests() {
failedTests = 0;
passedTests = 0;
Log.p("-----STARTING TESTS-----");
InputStream is = null;
DataInputStream di = null;
try {
InputStream is = DeviceRunner.class.getResourceAsStream("/tests.dat");
is = DeviceRunner.class.getResourceAsStream("/tests.dat");

if (is == null) {
is = Display.getInstance().getResourceAsStream(null, "/tests.dat");
Expand All @@ -60,7 +63,7 @@ public void runTests() {
System.exit(2);
return;
}
DataInputStream di = new DataInputStream(is);
di = new DataInputStream(is);
int version = di.readInt();
if (version > VERSION) {
Log.p("Tests were built with a new version of Codename One and can't be executed with this runner");
Expand All @@ -72,13 +75,16 @@ public void runTests() {
for (int iter = 0; iter < tests.length; iter++) {
tests[iter] = di.readUTF();
}
di.close();
Util.cleanup(di);

for (int iter = 0; iter < tests.length; iter++) {
runTest(tests[iter]);
for (String test : tests) {
runTest(test);
}
} catch (IOException err) {
TestReporting.getInstance().logException(err);
} finally {
Util.cleanup(is);
Util.cleanup(di);
}
TestReporting.getInstance().testExecutionFinished(getClass().getName());
if (failedTests > 0) {
Expand Down
41 changes: 41 additions & 0 deletions maven/core-unittests/spotbugs-exclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,47 @@
<Class name="~com\.codename1\.io\.gzip\.Inflate.*" />
<Bug pattern="SF_SWITCH_FALLTHROUGH" />
</Match>
<Match>
<Class name="~com\.codename1\.io\.gzip\.Deflate.*" />
<Bug pattern="ICAST_QUESTIONABLE_UNSIGNED_RIGHT_SHIFT" />
</Match>

<!--
There are two failures for this specific bug:
com.codename1.ui.Container.setLightweightMode(boolean)
com.codename1.impl.CodenameOneImplementation.playBuiltinSound(String)

Lightweight mode is useful in peer components, which is only
visible in the native layer (invisible to spotbugs).
playBuiltinSound seems unused, but we probably would want to fix
that at some point.
-->
<Match>
<Bug pattern="UC_USELESS_VOID_METHOD" />
</Match>

<!--
These are actual bugs we're ignoring specifically:
components isn't initialized in com.codename1.ui.Container.initLaf(UIManager) when invoked from constructor for superclass
fontIconSize isn't initialized in com.codename1.ui.Label.initLaf(UIManager) when invoked from constructor for superclass
materialIconSize isn't initialized in com.codename1.ui.Label.initLaf(UIManager) when invoked from constructor for superclass

Unfortunately, we can't fix them without breaking Codename One.
initLaf is deeply embedded in the code and the constructor chain,
and we just can't fix it properly.
-->
<Match>
<Bug pattern="UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR" />
</Match>

<!--
This fires for timed waits which shouldn't be in a loop.
It's a bad check. In one particular case, it also misses a loop
in the parent (EDT main loop).
-->
<Match>
<Bug pattern="WA_NOT_IN_LOOP" />
</Match>

<!--
This rule is a bit broad for the complex threading logic in Display.
Expand Down
Loading