mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 11:04:34 +02:00
6715757: javap does not print "extends java.lang.Object"
Reviewed-by: ksrini
This commit is contained in:
parent
fdd75a4bbb
commit
23aea10d3e
4 changed files with 16 additions and 25 deletions
|
@ -36,10 +36,6 @@ import java.util.List;
|
||||||
public class Type {
|
public class Type {
|
||||||
protected Type() { }
|
protected Type() { }
|
||||||
|
|
||||||
public boolean isObject() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static void append(StringBuilder sb, String prefix, List<? extends Type> types, String suffix) {
|
protected static void append(StringBuilder sb, String prefix, List<? extends Type> types, String suffix) {
|
||||||
sb.append(prefix);
|
sb.append(prefix);
|
||||||
String sep = "";
|
String sep = "";
|
||||||
|
@ -66,11 +62,6 @@ public class Type {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isObject() {
|
|
||||||
return name.equals("java.lang.Object");
|
|
||||||
}
|
|
||||||
|
|
||||||
public final String name;
|
public final String name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +120,7 @@ public class Type {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
appendIfNotEmpty(sb, "<", typeArgTypes, ">");
|
appendIfNotEmpty(sb, "<", typeArgTypes, ">");
|
||||||
if (superclassType != null && !superclassType.isObject()) {
|
if (superclassType != null) {
|
||||||
sb.append(" extends ");
|
sb.append(" extends ");
|
||||||
sb.append(superclassType);
|
sb.append(superclassType);
|
||||||
}
|
}
|
||||||
|
@ -188,7 +179,7 @@ public class Type {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append(name);
|
sb.append(name);
|
||||||
String sep = " extends ";
|
String sep = " extends ";
|
||||||
if (classBound != null && !classBound.isObject()) {
|
if (classBound != null) {
|
||||||
sb.append(sep);
|
sb.append(sep);
|
||||||
sb.append(classBound);
|
sb.append(classBound);
|
||||||
sep = " & ";
|
sep = " & ";
|
||||||
|
|
|
@ -104,15 +104,11 @@ public class ClassWriter extends BasicWriter {
|
||||||
Signature_attribute sigAttr = getSignature(cf.attributes);
|
Signature_attribute sigAttr = getSignature(cf.attributes);
|
||||||
if (sigAttr == null) {
|
if (sigAttr == null) {
|
||||||
// use info from class file header
|
// use info from class file header
|
||||||
if (classFile.isClass()) {
|
if (classFile.isClass() && classFile.super_class != 0 ) {
|
||||||
if (classFile.super_class != 0 ) {
|
|
||||||
String sn = getJavaSuperclassName(cf);
|
String sn = getJavaSuperclassName(cf);
|
||||||
if (!sn.equals("java.lang.Object") || options.compat) { // BUG XXXXXXXX
|
|
||||||
print(" extends ");
|
print(" extends ");
|
||||||
print(sn);
|
print(sn);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int i = 0; i < classFile.interfaces.length; i++) {
|
for (int i = 0; i < classFile.interfaces.length; i++) {
|
||||||
print(i == 0 ? (classFile.isClass() ? " implements " : " extends ") : ",");
|
print(i == 0 ? (classFile.isClass() ? " implements " : " extends ") : ",");
|
||||||
print(getJavaInterfaceName(classFile, i));
|
print(getJavaInterfaceName(classFile, i));
|
||||||
|
@ -124,7 +120,7 @@ public class ClassWriter extends BasicWriter {
|
||||||
// FieldType and a ClassSignatureType that only contains a superclass type.
|
// FieldType and a ClassSignatureType that only contains a superclass type.
|
||||||
if (t instanceof Type.ClassSigType)
|
if (t instanceof Type.ClassSigType)
|
||||||
print(t);
|
print(t);
|
||||||
else if (!t.isObject()) {
|
else {
|
||||||
print(" extends ");
|
print(" extends ");
|
||||||
print(t);
|
print(t);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,9 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 4870651
|
* @bug 4870651 6715757
|
||||||
* @summary javap should recognize generics, varargs, enum
|
* @summary javap should recognize generics, varargs, enum;
|
||||||
|
* javap prints "extends java.lang.Object"
|
||||||
* @build T4870651 Test
|
* @build T4870651 Test
|
||||||
* @run main T4870651
|
* @run main T4870651
|
||||||
*/
|
*/
|
||||||
|
@ -38,7 +39,9 @@ public class T4870651 {
|
||||||
|
|
||||||
public void run() throws IOException {
|
public void run() throws IOException {
|
||||||
verify("Test",
|
verify("Test",
|
||||||
"class Test<T, E extends java.lang.Exception & java.lang.Comparable<T>, U extends java.lang.Comparable>",
|
"class Test<T extends java.lang.Object, " +
|
||||||
|
"E extends java.lang.Exception & java.lang.Comparable<T>, " +
|
||||||
|
"U extends java.lang.Comparable>",
|
||||||
"v1(java.lang.String...)");
|
"v1(java.lang.String...)");
|
||||||
|
|
||||||
verify("Test$Enum",
|
verify("Test$Enum",
|
||||||
|
|
|
@ -23,8 +23,9 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 4880663
|
* @bug 4880663 6715757
|
||||||
* @summary javap could output whitespace between class name and opening brace
|
* @summary javap could output whitespace between class name and opening brace
|
||||||
|
* javap prints "extends java.lang.Object"
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,7 +39,7 @@ public class T4880663 {
|
||||||
public void run() throws IOException {
|
public void run() throws IOException {
|
||||||
File javaFile = writeTestFile();
|
File javaFile = writeTestFile();
|
||||||
File classFile = compileTestFile(javaFile);
|
File classFile = compileTestFile(javaFile);
|
||||||
verify(classFile, "class Test {");
|
verify(classFile, "class Test extends java.lang.Object {");
|
||||||
|
|
||||||
if (errors > 0)
|
if (errors > 0)
|
||||||
throw new Error(errors + " found.");
|
throw new Error(errors + " found.");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue