Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 2 additions & 19 deletions src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java
Original file line number Diff line number Diff line change
Expand Up @@ -2279,30 +2279,13 @@ private boolean shouldEmitOuterThis(ClassSymbol sym) {
// Enclosing instance field is used
return true;
}
if (rs.isSerializable(sym.type) && !hasSerialVersionUID(sym)) {
// Class is serializable and does not have a stable serialVersionUID
if (rs.isSerializable(sym.type)) {
// Class is serializable
return true;
}
return false;
}

private boolean hasSerialVersionUID(ClassSymbol sym) {
VarSymbol svuid = (VarSymbol) sym.members().findFirst(names.serialVersionUID, f -> f.kind == VAR);
if (svuid == null) {
return false;
}
if ((svuid.flags() & (STATIC | FINAL)) != (STATIC | FINAL)) {
return false;
}
if (!svuid.type.hasTag(LONG)) {
return false;
}
if (svuid.getConstValue() == null) {
return false;
}
return true;
}

List<JCTree> generateMandatedAccessors(JCClassDecl tree) {
List<JCVariableDecl> fields = TreeInfo.recordFields(tree);
return tree.sym.getRecordComponents().stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void test() {
checkInner(N0.N1.N2.N3.N4.N5.class, false);

checkInner(SerializableCapture.class, true);
checkInner(SerializableWithSerialVersionUID.class, false);
checkInner(SerializableWithSerialVersionUID.class, true);
checkInner(SerializableWithInvalidSerialVersionUIDType.class, true);
checkInner(SerializableWithInvalidSerialVersionUIDNonFinal.class, true);
checkInner(SerializableWithInvalidSerialVersionUIDNonStatic.class, true);
Expand Down