Reputation: 5647
I have a maven project with a bunch of dependencies, one of which I'd like to print a line to console to called pulsar-log4j2-appender
. I tried opening the .class file in question by following in Intellij:
External Libraries | Maven: org.apache.pulsar:pulsar-log4j2-appender:2.6.0 | pulsar-log4j2-appender-2.6.0.jar | org.apache.pulsar.log4j2.appender | PulsarManager.class
When I try to add a System.out.println statement, Intellij says the file is read only:
Upvotes: 0
Views: 2012
Reputation: 2728
Powered by Java bytecode decompiler plugin, IntelliJ decompiles Java bytecode into human-readable Java code When you try to open .class
extension
Now, you're actually viewing Java decompiled bytecode(can't be edited inside the IDE), not actual Java code (.java
extension).
The solution would be to modify the source code itself and rebuild it.
More info: https://blog.jetbrains.com/idea/2020/03/java-bytecode-decompiler/
Upvotes: 3
Reputation: 35805
You cannot change code in external Maven dependencies.
You can debug them, though, with the debugger of your IDE and watch the values you are interested in.
If you really want to change the code, you need to find the project (e.g. on Github), check it out and build it yourself.
Upvotes: 6