stokito / IdeaJol

Intellij plugin that shows an object layout in memory to help optimize it. Uses OpenJDK JOL tool
https://plugins.jetbrains.com/plugin/10953-java-object-layout
Apache License 2.0
141 stars 9 forks source link

support for lombok #21

Closed taotao365s closed 5 years ago

taotao365s commented 5 years ago

when I use lombok , this plugin not show anything. 'Code | show Object layout' is disabled.

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
stokito commented 5 years ago

Lombok is a cancer, don't use it and punch everyone who even said that word. Any code preprocessors are prohibited in Java by design. Anybody who decided to use it should be disqualified as a programmer. Unfortunately the cancer had spread further so even in my project I have to deal with this shit.

Actually it should work because IdeaJol just looking for fields. So those @Data and other annotations should not affect this. I just checked and I see an exception:

Unable to generate layout
java.lang.NullPointerException
    at com.github.stokito.IdeaJol.toolwindow.JolView.setupUI(JolView.java:56)
    at com.github.stokito.IdeaJol.toolwindow.JolView.<init>(JolView.java:52)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
    at org.picocontainer.defaults.InstantiatingComponentAdapter.newInstance(InstantiatingComponentAdapter.java:193)
    at com.intellij.util.pico.CachingConstructorInjectionComponentAdapter.doGetComponentInstance(CachingConstructorInjectionComponentAdapter.java:88)
    at com.intellij.util.pico.CachingConstructorInjectionComponentAdapter.instantiateGuarded(CachingConstructorInjectionComponentAdapter.java:66)

So actually this is a bug. I'll mark this ticket as a bug but even if anyway it won't work with Lombok then I'll do nothing for this. The only possibility to support it or any other shitty tool that changes bytecode: we can analyze a raw bytecode as the original JOL do. Thus you'll need to compile a class before analyzing and we can't add an inspection for this. But this at least something. The corresponding ticket is #16

stokito commented 5 years ago

ok, it turned out that that exception was because the plugin wasn't properly built on my system and actually the plugin works even with a class annotated with lombok. So I don't know what was a point of your ticket all. Could you clarify what exactly you wanted? Just curious

stokito commented 5 years ago

this plugin not show anything. 'Code | show Object layout' is disabled.

you can enable this inspection but it quote annoying. Also you can put cursor on any class name then press Alt+Enter and click on Show the object layout to see it's layout.