6715757: javap does not print "extends java.lang.Object"
Reviewed-by: ksrini
This commit is contained in:
parent
fdd75a4bbb
commit
23aea10d3e
@ -36,10 +36,6 @@ import java.util.List;
|
||||
public class Type {
|
||||
protected Type() { }
|
||||
|
||||
public boolean isObject() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected static void append(StringBuilder sb, String prefix, List<? extends Type> types, String suffix) {
|
||||
sb.append(prefix);
|
||||
String sep = "";
|
||||
@ -66,11 +62,6 @@ public class Type {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isObject() {
|
||||
return name.equals("java.lang.Object");
|
||||
}
|
||||
|
||||
public final String name;
|
||||
}
|
||||
|
||||
@ -129,7 +120,7 @@ public class Type {
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
appendIfNotEmpty(sb, "<", typeArgTypes, ">");
|
||||
if (superclassType != null && !superclassType.isObject()) {
|
||||
if (superclassType != null) {
|
||||
sb.append(" extends ");
|
||||
sb.append(superclassType);
|
||||
}
|
||||
@ -188,7 +179,7 @@ public class Type {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(name);
|
||||
String sep = " extends ";
|
||||
if (classBound != null && !classBound.isObject()) {
|
||||
if (classBound != null) {
|
||||
sb.append(sep);
|
||||
sb.append(classBound);
|
||||
sep = " & ";
|
||||
|
@ -104,14 +104,10 @@ public class ClassWriter extends BasicWriter {
|
||||
Signature_attribute sigAttr = getSignature(cf.attributes);
|
||||
if (sigAttr == null) {
|
||||
// use info from class file header
|
||||
if (classFile.isClass()) {
|
||||
if (classFile.super_class != 0 ) {
|
||||
String sn = getJavaSuperclassName(cf);
|
||||
if (!sn.equals("java.lang.Object") || options.compat) { // BUG XXXXXXXX
|
||||
print(" extends ");
|
||||
print(sn);
|
||||
}
|
||||
}
|
||||
if (classFile.isClass() && classFile.super_class != 0 ) {
|
||||
String sn = getJavaSuperclassName(cf);
|
||||
print(" extends ");
|
||||
print(sn);
|
||||
}
|
||||
for (int i = 0; i < classFile.interfaces.length; i++) {
|
||||
print(i == 0 ? (classFile.isClass() ? " implements " : " extends ") : ",");
|
||||
@ -124,7 +120,7 @@ public class ClassWriter extends BasicWriter {
|
||||
// FieldType and a ClassSignatureType that only contains a superclass type.
|
||||
if (t instanceof Type.ClassSigType)
|
||||
print(t);
|
||||
else if (!t.isObject()) {
|
||||
else {
|
||||
print(" extends ");
|
||||
print(t);
|
||||
}
|
||||
|
@ -23,8 +23,9 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4870651
|
||||
* @summary javap should recognize generics, varargs, enum
|
||||
* @bug 4870651 6715757
|
||||
* @summary javap should recognize generics, varargs, enum;
|
||||
* javap prints "extends java.lang.Object"
|
||||
* @build T4870651 Test
|
||||
* @run main T4870651
|
||||
*/
|
||||
@ -38,7 +39,9 @@ public class T4870651 {
|
||||
|
||||
public void run() throws IOException {
|
||||
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...)");
|
||||
|
||||
verify("Test$Enum",
|
||||
|
@ -23,8 +23,9 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4880663
|
||||
* @bug 4880663 6715757
|
||||
* @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 {
|
||||
File javaFile = writeTestFile();
|
||||
File classFile = compileTestFile(javaFile);
|
||||
verify(classFile, "class Test {");
|
||||
verify(classFile, "class Test extends java.lang.Object {");
|
||||
|
||||
if (errors > 0)
|
||||
throw new Error(errors + " found.");
|
||||
|
Loading…
Reference in New Issue
Block a user