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
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ class BuildPlugin implements Plugin<Project> {
heapdumpDir.mkdirs()
jvmArg '-XX:HeapDumpPath=' + heapdumpDir
argLine System.getProperty('tests.jvm.argline')
argLine '-XX:-OmitStackTraceInFastThrow'

// we use './temp' since this is per JVM and tests are forbidden from writing to CWD
systemProperty 'java.io.tmpdir', './temp'
Expand Down
4 changes: 4 additions & 0 deletions distribution/src/main/resources/config/jvm.options
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@
# use our provided JNA always versus the system one
-Djna.nosys=true

# turn off a JDK optimization that throws away stack traces for common
# exceptions because stack traces are important for debugging
-XX:-OmitStackTraceInFastThrow

# use old-style file permissions on JDK9
-Djdk.io.permissionsUseCanonicalPath=true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,14 @@ private void expectOutOfBounds(int index, String script, Object val) {
IndexOutOfBoundsException e = expectScriptThrows(IndexOutOfBoundsException.class, () ->
exec(script, singletonMap("val", val), true));
try {
/* If this fails you *might* be missing -XX:-OmitStackTraceInFastThrow in the test jvm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to nit, I think that this is cleaner for multi-line comments:

/*
 * Text goes here.
 * A blank line above and below makes it clean.
 */

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the stately form of multiline comments for javadocs and really long comments that have to stand out but I tend to prefer this one for single line comments that happen to be long enough that they end up on multiple lines. Clear as mud?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clear as mud?

Indeed. 😐

* In Eclipse you can add this by default by going to Preference->Java->Installed JREs,
* clicking on the default JRE, clicking edit, and adding the flag to the
* "Default VM Arguments".
*/
assertThat(e.getMessage(), outOfBoundsExceptionMessageMatcher(index, 5));
} catch (AssertionError ae) {
ae.addSuppressed(e); // Mark the exception we are testing as suppressed so we get its stack trace. If it has one :(
ae.addSuppressed(e); // Mark the exception we are testing as suppressed so we get its stack trace.
throw ae;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
import java.util.Arrays;
import java.util.List;

import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue;

/** Tests for working with lists. */
public class ListTests extends ArrayLikeObjectTestCase {
Expand Down Expand Up @@ -61,10 +59,7 @@ protected Matcher<String> outOfBoundsExceptionMessageMatcher(int index, int size
if (index > size) {
return equalTo("Index: " + index + ", Size: " + size);
}
Matcher<String> matcher = equalTo(Integer.toString(index));
// If we set -XX:-OmitStackTraceInFastThrow we wouldn't need this
matcher = anyOf(matcher, nullValue());
return matcher;
return equalTo(Integer.toString(index));
} else {
// This exception is locale dependent so we attempt to reproduce it
List<Object> list = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,13 @@ public static <T extends Throwable> T expectScriptThrows(Class<T> expectedType,
if (e instanceof ScriptException) {
boolean hasEmptyScriptStack = ((ScriptException) e).getScriptStack().isEmpty();
if (shouldHaveScriptStack && hasEmptyScriptStack) {
if (0 != e.getCause().getStackTrace().length) {
// Without -XX:-OmitStackTraceInFastThrow the jvm can eat the stack trace which causes us to ignore script_stack
AssertionFailedError assertion = new AssertionFailedError("ScriptException should have a scriptStack");
assertion.initCause(e);
throw assertion;
}
/* If this fails you *might* be missing -XX:-OmitStackTraceInFastThrow in the test jvm
* In Eclipse you can add this by default by going to Preference->Java->Installed JREs,
* clicking on the default JRE, clicking edit, and adding the flag to the
* "Default VM Arguments". */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A blank line above and below. 😄

AssertionFailedError assertion = new AssertionFailedError("ScriptException should have a scriptStack");
assertion.initCause(e);
throw assertion;
} else if (false == shouldHaveScriptStack && false == hasEmptyScriptStack) {
AssertionFailedError assertion = new AssertionFailedError("ScriptException shouldn't have a scriptStack");
assertion.initCause(e);
Expand Down