8047024: 7 ANNOT tests in JCK9 test suite fail with an AssertionError for exception_index

Fix incorrect assertion about exception index already being set.

Reviewed-by: mcimadamore
This commit is contained in:
Srikanth Adayapalam 2016-05-25 19:30:55 +05:30
parent fea34ed634
commit 93714ca994
3 changed files with 82 additions and 6 deletions

View File

@ -148,9 +148,10 @@ public class TypeAnnotationPosition {
// For exception parameters, index into exception table. In
// com.sun.tools.javac.jvm.Gen.genCatch, we first use this to hold
// the catch type index. Then in
// the catch type's constant pool entry index. Then in
// com.sun.tools.javac.jvm.Code.fillExceptionParameterPositions we
// use that value to determine the exception table index.
// When read from class file, this holds
private int exception_index = Integer.MIN_VALUE;
// If this type annotation is within a lambda expression,
@ -303,13 +304,13 @@ public class TypeAnnotationPosition {
}
public int getExceptionIndex() {
Assert.check(exception_index >= 0, "exception_index does not contain a bytecode offset");
Assert.check(exception_index >= 0, "exception_index is not set");
return exception_index;
}
public void setExceptionIndex(final int exception_index) {
Assert.check(hasCatchType(), "exception_index already contains a bytecode offset");
Assert.check(exception_index >= 0, "Expected a valid bytecode offset");
Assert.check(!hasExceptionIndex(), "exception_index already set");
Assert.check(exception_index >= 0, "Expected a valid index into exception table");
this.exception_index = exception_index;
}
@ -330,8 +331,8 @@ public class TypeAnnotationPosition {
}
public void setCatchInfo(final int catchType, final int startPos) {
Assert.check(this.exception_index < 0,
"exception_index already contains a bytecode index");
Assert.check(!hasExceptionIndex(),
"exception_index is already set");
Assert.check(catchType >= 0, "Expected a valid catch type");
this.exception_index = -((catchType | startPos << 8) + 1);
}

View File

@ -0,0 +1,36 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8047024
* @summary AssertionError: exception_index already contains a bytecode offset
* @compile T8047024_01.java
* @compile -XDsave-parameter-names=true T8047024.java
*/
public class T8047024 {
public static void main(String [] args) {
T8047024_01.run();
}
}

View File

@ -0,0 +1,39 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
public class T8047024_01 {
@Target(ElementType.TYPE_USE)
@interface TA {}
public static void run() {
try {
System.out.println("");
} catch (@TA Throwable e) {
}
}
}