Skip to content

Commit cd8c40e

Browse files
committed
Kotlin: Enable java/non-serializable-field for Kotlin
It now ignores compiler-generated classes
1 parent d53d275 commit cd8c40e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

java/ql/src/Likely Bugs/Serialization/NonSerializableField.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ string nonSerialReason(RefType t) {
5555
predicate exceptions(Class c, Field f) {
5656
f.getDeclaringType() = c and
5757
(
58+
c.isCompilerGenerated()
59+
or
5860
// `Serializable` objects with custom `readObject` or `writeObject` methods
5961
// may write out the "non-serializable" fields in a different way.
6062
c.declaresMethod("readObject")
@@ -90,7 +92,7 @@ predicate exceptions(Class c, Field f) {
9092

9193
from Class c, Field f, string reason
9294
where
93-
c.getFile().isJavaSourceFile() and
95+
c.fromSource() and
9496
c.getAStrictAncestor() instanceof TypeSerializable and
9597
f.getDeclaringType() = c and
9698
not exceptions(c, f) and
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* The query `java/non-serializable-field` is now enabled for Kotlin.

0 commit comments

Comments
 (0)