diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java index 374e18fb0a5..7b2ccb7f426 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java @@ -2279,30 +2279,13 @@ public class Lower extends TreeTranslator { // 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 generateMandatedAccessors(JCClassDecl tree) { List fields = TreeInfo.recordFields(tree); return tree.sym.getRecordComponents().stream() diff --git a/test/langtools/tools/javac/optimizeOuterThis/OptimizeOuterThis.java b/test/langtools/tools/javac/optimizeOuterThis/OptimizeOuterThis.java index 1a01d61f94e..a42508e2a0a 100644 --- a/test/langtools/tools/javac/optimizeOuterThis/OptimizeOuterThis.java +++ b/test/langtools/tools/javac/optimizeOuterThis/OptimizeOuterThis.java @@ -64,7 +64,7 @@ public class OptimizeOuterThis extends InnerClasses { 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);