8019397: javap does not show SourceDebugExtension properly
Reviewed-by: jjg
Contributed-by: dmytro_sheyko@hotmail.com
--- a/langtools/src/share/classes/com/sun/tools/classfile/SourceDebugExtension_attribute.java Mon Jul 01 11:58:45 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/classfile/SourceDebugExtension_attribute.java Tue Jul 02 10:21:41 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, 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
@@ -28,6 +28,7 @@
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
+import java.nio.charset.Charset;
/**
* See JVMS, section 4.8.15.
@@ -38,6 +39,8 @@
* deletion without notice.</b>
*/
public class SourceDebugExtension_attribute extends Attribute {
+ private static final Charset UTF8 = Charset.forName("UTF-8");
+
SourceDebugExtension_attribute(ClassReader cr, int name_index, int length) throws IOException {
super(name_index, length);
debug_extension = new byte[attribute_length];
@@ -55,12 +58,7 @@
}
public String getValue() {
- DataInputStream d = new DataInputStream(new ByteArrayInputStream(debug_extension));
- try {
- return d.readUTF();
- } catch (IOException e) {
- return null;
- }
+ return new String(debug_extension, UTF8);
}
public <R, D> R accept(Visitor<R, D> visitor, D data) {
--- a/langtools/src/share/classes/com/sun/tools/javap/AttributeWriter.java Mon Jul 01 11:58:45 2013 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javap/AttributeWriter.java Tue Jul 02 10:21:41 2013 +0100
@@ -513,7 +513,12 @@
}
public Void visitSourceDebugExtension(SourceDebugExtension_attribute attr, Void ignore) {
- println("SourceDebugExtension: " + attr.getValue());
+ println("SourceDebugExtension:");
+ indent(+1);
+ for (String s: attr.getValue().split("[\r\n]+")) {
+ println(s);
+ }
+ indent(-1);
return null;
}