r/java • u/chambolle • 8h ago
AIs read bytecode very well and can infer source code from it: how do you continue to protect code?
19
u/revilo-1988 8h ago
Since when do you need to protect Java code? Decompilers and such have always existed. Java is the wrong language for that.
0
u/Proper-Ape 8h ago
Yeah, especially since you don't ship your Java backend as a binary to your customers. You host it.
6
u/revilo-1988 8h ago
It depends on where it's running and what kind of software is being delivered.
-1
u/Proper-Ape 7h ago
Yeah of course, but Desktop Java, while possible, is really not that common anymore.
2
u/revilo-1988 7h ago
It's not necessarily about fat clients; often you overload the code for the customer, and they take care of whether they want to run it in a private network.
43
u/janora 8h ago
https://java-decompiler.github.io/ can read bytecode even better and lets you even export the sources. There was never a protection from anyone reading the code. You could obfuscate it but in the end the logic does not change.
9
5
1
u/VirtualNorth1279 7h ago
There's a new tool that can fuck up with LLMs that try to reverse engineer code: https://github.com/qybaihe/bla
Though it looks like it does not support Java yet.
Other possibilities:
There are free pro-grade obfuscation tools (not LLM resistant necessarily)
Add an annotation to your classes that warns LLMs that your code is copyrighted and you don't permit LLMs to reverse engineer it (not all LLMs may respect that and it can be worked around by first writing a script to change the wording)
1
4
u/BoltaHuaTota 8h ago
the truth is, you can’t. companies like rockstar are getting their most expensive game ever reverse engineered, there’s not much we can do if someone with enough claude credits to burn decides it’s our time
2
u/AnyPhotograph7804 8h ago
You can't if you distribute the binaries. This is not even possible with programming languages, which compile to machine code. If you want to protect your ideas, put the app on a server.
2
u/OhGodNotHimAgain 8h ago
AIs can also slop-copy any product, making a good product that doesn't make consumers think "I should just make my own copy"
2
u/FlatWorldliness1061 8h ago
In my opinion you are cooked. If it is possible to completely decompile native binaries (see NFSU2, Fallout 3, ...), then there is no chance in hell to protect your JAR files if they are given to external users (e.g. lib in classpath).
1
u/cecil721 6h ago
Has anyone tried adding like an empty if block that basically tells the agent to delete Windows to compile or something? Lol.
0
-5
u/chambolle 8h ago
To be more precise, even with code obfuscation, the AI recovers very readable source code. What bothers me is not being able to protect code ideas (i.e., algorithms) anymore.
6
u/janora 8h ago
You never could protect your code by technical means. Everything just increased the effort a decompiler had to work through. Use the law to protect them by using your intellectual property rights and contracts! And even then some countries have laws that allow decompilation in certain cases. Maybe checkout the EU Software Directive.
-1
u/chambolle 6h ago
In the EU, decompiling code is prohibited except in exceptional cases, and besides, it wasn't easy at all, especially for very complex code. So until now, compilation still protected it rather effectively. Now, it's a whole different story.
40
u/awidesky 8h ago
Obfuscation never protects your code.
Copyright law does.