Merge pull request #11437 from igfoo/igfoo/NonSerializableField

Kotlin: Enable java/non-serializable-field for Kotlin
This commit is contained in:
Ian Lynagh
2022-12-01 11:01:15 +00:00
committed by GitHub
2 changed files with 7 additions and 1 deletions

View File

@@ -55,6 +55,8 @@ string nonSerialReason(RefType t) {
predicate exceptions(Class c, Field f) {
f.getDeclaringType() = c and
(
c.isCompilerGenerated()
or
// `Serializable` objects with custom `readObject` or `writeObject` methods
// may write out the "non-serializable" fields in a different way.
c.declaresMethod("readObject")
@@ -90,7 +92,7 @@ predicate exceptions(Class c, Field f) {
from Class c, Field f, string reason
where
c.getFile().isJavaSourceFile() and
c.fromSource() and
c.getAStrictAncestor() instanceof TypeSerializable and
f.getDeclaringType() = c and
not exceptions(c, f) and

View File

@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* The query `java/non-serializable-field` is now enabled for Kotlin.