8277965: Enclosing instance optimization affects serialization
Reviewed-by: darcy
This commit is contained in:
parent
8f196a2487
commit
4f15be2cd4
@ -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<JCTree> generateMandatedAccessors(JCClassDecl tree) {
|
||||
List<JCVariableDecl> fields = TreeInfo.recordFields(tree);
|
||||
return tree.sym.getRecordComponents().stream()
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user