mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 19:14:38 +02:00
8019397: javap does not show SourceDebugExtension properly
Reviewed-by: jjg
This commit is contained in:
parent
547a050fe1
commit
ba85477f84
2 changed files with 11 additions and 8 deletions
|
@ -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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -28,6 +28,7 @@ package com.sun.tools.classfile;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See JVMS, section 4.8.15.
|
* See JVMS, section 4.8.15.
|
||||||
|
@ -38,6 +39,8 @@ import java.io.IOException;
|
||||||
* deletion without notice.</b>
|
* deletion without notice.</b>
|
||||||
*/
|
*/
|
||||||
public class SourceDebugExtension_attribute extends Attribute {
|
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 {
|
SourceDebugExtension_attribute(ClassReader cr, int name_index, int length) throws IOException {
|
||||||
super(name_index, length);
|
super(name_index, length);
|
||||||
debug_extension = new byte[attribute_length];
|
debug_extension = new byte[attribute_length];
|
||||||
|
@ -55,12 +58,7 @@ public class SourceDebugExtension_attribute extends Attribute {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
DataInputStream d = new DataInputStream(new ByteArrayInputStream(debug_extension));
|
return new String(debug_extension, UTF8);
|
||||||
try {
|
|
||||||
return d.readUTF();
|
|
||||||
} catch (IOException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public <R, D> R accept(Visitor<R, D> visitor, D data) {
|
public <R, D> R accept(Visitor<R, D> visitor, D data) {
|
||||||
|
|
|
@ -513,7 +513,12 @@ public class AttributeWriter extends BasicWriter
|
||||||
}
|
}
|
||||||
|
|
||||||
public Void visitSourceDebugExtension(SourceDebugExtension_attribute attr, Void ignore) {
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue