Skip to content

Commit eac26f4

Browse files
committed
8296709: WARNING: JNI call made without checking exceptions
Reviewed-by: kevinw, sspitsyn, clanger
1 parent 4946737 commit eac26f4

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

src/jdk.jdwp.agent/share/native/libjdwp/util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,12 +275,12 @@ util_initialize(JNIEnv *env)
275275
localAgentProperties =
276276
JNI_FUNC_PTR(env,CallStaticObjectMethod)
277277
(env, localVMSupportClass, getAgentProperties);
278-
saveGlobalRef(env, localAgentProperties, &(gdata->agent_properties));
279278
if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
280279
JNI_FUNC_PTR(env,ExceptionClear)(env);
281280
EXIT_ERROR(AGENT_ERROR_INTERNAL,
282281
"Exception occurred calling VMSupport.getAgentProperties");
283282
}
283+
saveGlobalRef(env, localAgentProperties, &(gdata->agent_properties));
284284
}
285285

286286
} END_WITH_LOCAL_REFS(env);

test/jdk/ProblemList.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,11 @@ sanity/client/SwingSet/src/ButtonDemoScreenshotTest.java 8265770 macosx-all
691691
# core_tools
692692

693693

694+
############################################################################
695+
696+
# core_svc
697+
tools/launcher/TestXcheckJNIWarnings.java#jdwp-agent 8296936 generic-all
698+
694699
############################################################################
695700

696701
# jdk_jdi

test/jdk/tools/launcher/TestXcheckJNIWarnings.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -25,14 +25,22 @@
2525
import java.io.IOException;
2626

2727
/**
28-
* @test
28+
* @test id=noagent
2929
* @bug 8187442
3030
* @summary Launching app shouldn't produce any jni warnings.
3131
* @modules jdk.compiler
3232
* jdk.zipfs
33-
* @compile TestXcheckJNIWarnings.java
3433
* @run main TestXcheckJNIWarnings
3534
*/
35+
36+
/**
37+
* @test id=jdwp-agent
38+
* @bug 8187442
39+
* @summary Launching app with jdwp agent shouldn't produce any jni warnings.
40+
* @modules jdk.compiler
41+
* jdk.zipfs
42+
* @run main TestXcheckJNIWarnings -agentlib:jdwp=transport=dt_socket,server=y,suspend=n
43+
*/
3644
public final class TestXcheckJNIWarnings extends TestHelper {
3745

3846
static void createJarFile(File testJar) throws IOException {
@@ -46,8 +54,14 @@ static void createJarFile(File testJar) throws IOException {
4654
public static void main(String... args) throws IOException {
4755
File testJarFile = new File("test.jar");
4856
createJarFile(testJarFile);
49-
TestResult tr = doExec(javaCmd, "-jar", "-Xcheck:jni",
50-
testJarFile.getName());
57+
58+
TestResult tr;
59+
if (args.length > 0) {
60+
tr = doExec(javaCmd, "-jar", "-Xcheck:jni", args[0], testJarFile.getName());
61+
} else {
62+
tr = doExec(javaCmd, "-jar", "-Xcheck:jni", testJarFile.getName());
63+
}
64+
5165
if (!tr.isOK()) {
5266
System.out.println(tr);
5367
throw new RuntimeException("test returned non-positive value");

0 commit comments

Comments
 (0)