Skip to content

Commit

Permalink
Kotlin: Enable java/non-serializable-field for Kotlin
Browse files Browse the repository at this point in the history
It now ignores compiler-generated classes
  • Loading branch information
igfoo committed Nov 30, 2022
1 parent d53d275 commit cd8c40e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* The query `java/non-serializable-field` is now enabled for Kotlin.

0 comments on commit cd8c40e

Please sign in to comment.