-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Query for Java Static Initializer #16838
-
Hi, I am a junior developer and need some help with writing a query to capture the static initializer (static { ... }) of a Java class. Is this currently supported? If yes, could someone please point me to the right place in the documentation? Many thanks!
Beta Was this translation helpful? Give feedback.
All reactions
Hi,
In the database the static initialiser block becomes a block statement that is part of a static initialiser method. The easiest way I could find to get to it is as follows:
from Class c, StaticInitializer i, BlockStmt s where c.getAMethod() = i and i.getBody().getAChild() = s select s
Replies: 1 comment 2 replies
-
Hi,
In the database the static initialiser block becomes a block statement that is part of a static initialiser method. The easiest way I could find to get to it is as follows:
from Class c, StaticInitializer i, BlockStmt s where c.getAMethod() = i and i.getBody().getAChild() = s select s
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
Thanks for your response! Let me try this and let you know :)
Beta Was this translation helpful? Give feedback.
All reactions
-
Thank you, this worked!
Beta Was this translation helpful? Give feedback.