Comments (7)
Ah, it looks like the problem is that Krakatau tries to be helpful by removing the java.lang prefix from class names. But I'm hesitant to add it back in since in general it will lead to messier code. What do you suggest?
Anyway, AWT shouldn't be a problem because this is only done for java.lang.
from krakatau.
The package java.lang could be traversed for classes. If a java.lang class name is shadowed, the verbose behavior could be triggered. I don't know if this would require an extra run-through. Another option is a command line switch.
I think it should definitely be possible to get the correct behavior automatically, since it is possible to construct bytecode that shadows java.lang's classes on purpose (as an obfuscation method).
Also, it is not guaranteed that the incorrect code will not compile!
For example, if the constructor argument for the shadowing Integer class was a String, the invalid code would even compile, since the signature would match java.lang.Integer's String constructor! That would be an absolute nightmare to debug.
I think it is more important than the other issues I reported, since it can lead to compiling incorrect code.
Thanks for the quick reply.
from krakatau.
There are tons of ways to create bytecode that is impossible to represent in Java. The reason Krakatau is useful is because most obfuscators don't.
Anyway, I was hoping to avoid exhaustive directory searches to enumerate classes, but I think I may try adding it as a commandline switch.
from krakatau.
don't detect shadowing, it is too strict a condition to disable the full qualification of java.lang classes. thought the output would always be correct, sometimes it would not be clear enough for humans.
i propose: compile the set of all simple names of all referenced types in the current outer class and its nested children, except for java.lang types. when the name of java.lang type has to be output, use the fully qualified name if its simple name is in the set. this forces all fq names if there's a corresponding name clash anywhere in the current source file, which is a better policy for humans imho.
in fact this can be generalized: compile a map of all referenced types where simple name is key and fq name is value. while adding each type to the map, check for simple name clashes by detecting a would-be change of the existing value of the corresponding key, and if there is a clash replace the existing value with a sentinel. afterwards, use all non-sentinel entries to create type import statements. finally, whenever the name of type has to be output, use the fq name if the value mapped to its simple name is a sentinel.
still, two different types in the same VM can have the same fq name if they are loaded by different classloaders. the implications of this can be ignored until someone creates a very very nasty obfuscator.
from krakatau.
A flag to stop removal of java.lang.
?
from krakatau.
I'm not sure that's worth creating a flag for. If you want to patch it locally, it's only a 1 or 2 line change.
from krakatau.
Closing this since I stopped using Krakatau and I don't know whether it is still a bug.
from krakatau.
Related Issues (20)
- Re-assembled class fails to load (java/lang/ClassFormatError) HOT 11
- Assemble resource files HOT 2
- Decompilation error: AttributeError: 'NoneType' object has no attribute 'type' HOT 4
- try-catch class name causing UnicodeEncodeError: 'ascii' codec can't encode character u'\u200b' in position 0: ordinal not in range(128) HOT 2
- error Traceback (most recent call last) HOT 1
- illegal class/method/package names or modifiers HOT 2
- Interest in Krakatau 2? HOT 85
- bytecode peephole optimization non-looping-loops HOT 6
- Krakatau does not generate local variables info HOT 5
- Missing undocumented opcodes. HOT 3
- Cannot reassemble HOT 4
- is there any grammar book/doc for krak2? HOT 2
- When executing the command, an error "krak2 dis --out temp" HOT 2
- Fields without access flags have an extra space in the disassembly result.
- v2 seems not to have an option to assemble multiple classes into a single .jar HOT 7
- RuntimeError: maximum recursion depth exceeded while calling a Python object HOT 1
- crash with useless trycatches HOT 3
- Assemble .j files in Directory HOT 3
- 'rU' mode generate a backtrace in python 3.11+ HOT 3
- Issue with building "cargo build --release" HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from krakatau.