mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java] don't warn about @Serial on non-private serialVersionUID field (IDEA-321824)
GitOrigin-RevId: 726179763dabea03661d3a64696021f1b08fd8df
This commit is contained in:
committed by
intellij-monorepo-bot
parent
99ea9a50c6
commit
f9361a5042
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2021 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2024 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -120,20 +120,18 @@ public final class SerializationUtils {
|
||||
}
|
||||
|
||||
public static boolean isSerialVersionUid(@NotNull PsiField field) {
|
||||
return isConstant(field)
|
||||
return field.hasModifierProperty(PsiModifier.STATIC)
|
||||
&& field.hasModifierProperty(PsiModifier.FINAL)
|
||||
&& field.getName().equals(CommonClassNames.SERIAL_VERSION_UID_FIELD_NAME)
|
||||
&& field.getType().equals(PsiTypes.longType());
|
||||
}
|
||||
|
||||
public static boolean isSerialPersistentFields(@NotNull PsiField field) {
|
||||
return isConstant(field) && field.getName().equals("serialPersistentFields") &&
|
||||
field.getType().equalsToText("java.io.ObjectStreamField[]");
|
||||
}
|
||||
|
||||
private static boolean isConstant(@NotNull PsiField field) {
|
||||
return field.hasModifierProperty(PsiModifier.PRIVATE)
|
||||
&& field.hasModifierProperty(PsiModifier.STATIC)
|
||||
&& field.hasModifierProperty(PsiModifier.FINAL);
|
||||
&& field.hasModifierProperty(PsiModifier.FINAL)
|
||||
&& field.getName().equals("serialPersistentFields")
|
||||
&& field.getType().equalsToText("java.io.ObjectStreamField[]");
|
||||
}
|
||||
|
||||
public static boolean isProbablySerializable(PsiType type) {
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ import java.io.*;
|
||||
class Test implements Externalizable {
|
||||
|
||||
private static final long serialVersionID = 7874493593505141603L;
|
||||
static final long serialVersionUID = 7874493593505141603L;
|
||||
static final long <warning descr="'serialVersionUID' can be annotated with '@Serial' annotation">serialVersionUID</warning> = 7874493593505141603L;
|
||||
|
||||
private static final ObjectStreamField[] serialPersistentFields = new ObjectStreamField[0];
|
||||
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ import java.io.*;
|
||||
class Test implements Serializable {
|
||||
|
||||
private static final long serialVersionID = 7874493593505141603L;
|
||||
static final long serialVersionUID = 7874493593505141603L;
|
||||
static final long <warning descr="'serialVersionUID' can be annotated with '@Serial' annotation">serialVersionUID</warning> = 7874493593505141603L;
|
||||
|
||||
private static final ObjectStreamField[] serialPersistentFiels = new ObjectStreamField[0];
|
||||
private static ObjectStreamField[] serialPersistentFields = new ObjectStreamField[0];
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ class Test implements Externalizable {
|
||||
|
||||
<warning descr="Annotated member is not a part of the serialization mechanism">@Serial</warning>
|
||||
private static final long serialVersionID = 7874493593505141603L;
|
||||
<warning descr="Annotated member is not a part of the serialization mechanism">@Serial</warning>
|
||||
@Serial
|
||||
static final long serialVersionUID = 7874493593505141603L;
|
||||
|
||||
<warning descr="Annotated member is not a part of the serialization mechanism">@Serial</warning>
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ class Test implements Serializable {
|
||||
|
||||
<warning descr="Annotated member is not a part of the serialization mechanism">@Serial</warning>
|
||||
private static final long serialVersionID = 7874493593505141603L;
|
||||
<warning descr="Annotated member is not a part of the serialization mechanism">@Serial</warning>
|
||||
@Serial
|
||||
static final long serialVersionUID = 7874493593505141603L;
|
||||
|
||||
<warning descr="Annotated member is not a part of the serialization mechanism">@Serial</warning>
|
||||
|
||||
Reference in New Issue
Block a user