Uploaded image for project: 'Code Tools'
  1. Code Tools
  2. CODETOOLS-7902882

jtreg fails with ArrayIndexOutOfBoundsException when the type of an action is incorrect

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • jtreg7.6
    • None
    • tools
    • None

      Consider this trivial jtreg test:

      import org.testng.Assert;
      import org.testng.annotations.Test;


      /**
       * @test
       * @run @testng/othervm Foo
       */
      public class Foo {

          @Test
          public void testFoo() {
          }
      }

      Trying to run this as a jtreg test case fails with:

      execStatus=Error. Unexpected exception caught from test java/Foo.java\: java.lang.ArrayIndexOutOfBoundsException\: 1
      sections=script_messages Details

      #section:script_messages
      ----------messages:(0/0)----------

      #section:Details
      ----------messages:(0/0)----------
      ----------Stack trace:(6/413)----------
      java.lang.ArrayIndexOutOfBoundsException: 1
      at com.sun.javatest.regtest.exec.RegressionScript.parseActions(RegressionScript.java:392)
      at com.sun.javatest.regtest.exec.RegressionScript.run(RegressionScript.java:173)
      at com.sun.javatest.Script.run(Script.java:431)
      at com.sun.javatest.DefaultTestRunner.runTest(DefaultTestRunner.java:183)
      at com.sun.javatest.DefaultTestRunner$1.run(DefaultTestRunner.java:76)
      result: Not run. Test running...


      test result: Error. Unexpected exception caught from test java/Foo.java: java.lang.ArrayIndexOutOfBoundsException: 1


      Notice that in the test case, the type of the `@run` action is `@testng/othervm`. The `@testng` was accidental and instead should have been `testng/othervm`. The accidental use of @ character in the type of the run action seems to trigger this issue.

      Output from jtreg -version is as follows:

      jtreg, version 5.1 dev 1000
      Installed in ...
      Running on platform version 1.8.0_265 from ...
      Built with Java(TM) 2 SDK, Version 1.8.0_172-b11 on April 12, 2021.
      Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
      Use is subject to license terms.
      JT Harness, version 6.0 ea b11 (April 12, 2021)
      JCov 3.0-2
      TestNG (testng.jar): version unknown
      TestNG (jcommander.jar): version 1.72
      Java Assembler Tools, version 7.0 beta b02 (April 12, 2021)

            cstein Christian Stein
            jpai Jaikiran Pai
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: