[Patch] 8041793: javap misses newline after printing AnnotationDefault
Denis Istomin
istomin.den at gmail.com
Fri Jan 13 21:38:56 UTC 2017
Hi,
Made patch for bug 8041793.
--
Denis Istomin
-------------- next part --------------
# HG changeset patch
# User istomin
# Date 1484343294 -18000
# Sat Jan 14 02:34:54 2017 +0500
# Node ID dc10134e8d6f51bbd476fcb3ff32eedd93738329
# Parent cfa0d90539072c6b5459846ecd89b8162e012d78
8041793: javap misses newline after printing AnnotationDefault
diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/javap/AttributeWriter.java b/src/jdk.jdeps/share/classes/com/sun/tools/javap/AttributeWriter.java
--- a/src/jdk.jdeps/share/classes/com/sun/tools/javap/AttributeWriter.java
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/javap/AttributeWriter.java
@@ -164,6 +164,7 @@
print("default_value: ");
annotationWriter.write(attr.default_value);
indent(-1);
+ println();
return null;
}
diff --git a/test/tools/javap/typeAnnotations/AnnotationDefaultNewlineTest.java b/test/tools/javap/typeAnnotations/AnnotationDefaultNewlineTest.java
new file mode 100644
--- /dev/null
+++ b/test/tools/javap/typeAnnotations/AnnotationDefaultNewlineTest.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2013, 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 8041793
+ * @summary Verify that javap prints newline character after AnnotationDefault value
+ * @library /tools/lib
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ * jdk.compiler/com.sun.tools.javac.main
+ * jdk.jdeps/com.sun.tools.javap
+ * @build toolbox.ToolBox toolbox.JavacTask toolbox.JavapTask
+ * @run main AnnotationDefaultNewlineTest
+ */
+
+import toolbox.JavacTask;
+import toolbox.JavapTask;
+import toolbox.Task;
+import toolbox.ToolBox;
+
+public class AnnotationDefaultNewlineTest {
+
+ private static final String TestSrc =
+ "public @interface AnnotationDefault { \n" +
+ "public abstract int value() default 1; \n" +
+ "}";
+
+ private static final String ExpectedSubstring =
+ " AnnotationDefault:\n" +
+ " default_value: I#7\n";
+
+ public static void main(String[] args) throws Exception {
+ ToolBox tb = new ToolBox();
+ new JavacTask(tb).sources(TestSrc).run();
+
+ Task.Result res = new JavapTask(tb).options("-v").classes("AnnotationDefault.class").run();
+
+ String outString = res.getOutput(Task.OutputKind.DIRECT);
+ System.out.println(outString);
+ if (!outString.contains(ExpectedSubstring)) {
+ throw new Error("Error");
+ }
+ }
+}
More information about the compiler-dev
mailing list