RFR: Extend API to support JOL IntelliJ Idea plugin
Sergey Ponomarev
github.com+415502+stokito at openjdk.java.net
Tue Oct 6 14:55:15 UTC 2020
[JOL Intellij Idea Plugin](https://github.com/stokito/IdeaJol) internally uses JOL.
Internally in the
[PsiClassAdapter](https://github.com/stokito/IdeaJol/blob/master/src/main/java/com/github/stokito/IdeaJol/PsiClassAdapter.java)
it makes exactly the same as `org.openjdk.jol.info.ClassData#parse` but it creates the ClassData from Idea's AST/Psi
tree instead of raw `Class`. Unfortunately to be able to do this we need to extend API a little bit.
Here is a short list of changes that I did:
1. Added an overloaded method ClassData.addSuperClassData(ClassData) so I can create an instance of `ClassData`
2. Added `lossesInternal`, `lossesExternal` and `lossesTotal` fields to `ClassLayout` so they calculated only once on
instance creation and then can be accessed multiple times via geters by JTable 3. `FieldData.create()` internally
evaluate if the field is contended but we do this based on Psi tree. So we need to open and make public the `FieldData`
constructor.
-------------
Commit messages:
- ClassLayout: rename createClassLayout() to create()
- ClassLayout: add javadocs
- FieldData: expose full FieldData.create() constructor
- ClassLayout: rename loses variables for clearness
- ClassDataTest: add newline
- ClassLayout: calculate loosed bytes inside of createClassLayout()
- ClassLayout: call checkInvariants() from createClassLayout() instead of constructor
- Replace ClassLayout constructor with factory method
- ClassData: Return List instead of Collection
- ClassData: introduce addSuperClassData(ClassData)
Changes: https://git.openjdk.java.net/jol/pull/4/files
Webrev: https://webrevs.openjdk.java.net/?repo=jol&pr=4&range=00
Stats: 196 lines in 7 files changed: 169 ins; 10 del; 17 mod
Patch: https://git.openjdk.java.net/jol/pull/4.diff
Fetch: git fetch https://git.openjdk.java.net/jol pull/4/head:pull/4
PR: https://git.openjdk.java.net/jol/pull/4
More information about the jol-dev
mailing list