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
2525import 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+ */
3644public 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