# HG changeset patch # User sadayapalam # Date 1464184855 -19800 # Node ID b65bfa84144655ac55818074d1170cd8f4c73ac2 # Parent 9330543436402b8f3bd070524846a464d8143557 8047024: 7 ANNOT tests in JCK9 test suite fail with an AssertionError for exception_index Summary: Fix incorrect assertion about exception index already being set. Reviewed-by: mcimadamore diff -r 933054343640 -r b65bfa841446 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java Wed Jul 05 21:45:40 2017 +0200 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java Wed May 25 19:30:55 2016 +0530 @@ -148,9 +148,10 @@ // 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 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 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); } diff -r 933054343640 -r b65bfa841446 langtools/test/tools/javac/annotations/typeAnnotations/8047024/T8047024.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/annotations/typeAnnotations/8047024/T8047024.java Wed May 25 19:30:55 2016 +0530 @@ -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(); + } +} diff -r 933054343640 -r b65bfa841446 langtools/test/tools/javac/annotations/typeAnnotations/8047024/T8047024_01.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/annotations/typeAnnotations/8047024/T8047024_01.java Wed May 25 19:30:55 2016 +0530 @@ -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) { + + } + } +}