Comments (12)
This should probably be in the modlauncher, rather than the coremod system, since coremods are just a participant there.
from coremods.
I manually do the instruction printing from coremods when the transformation fails, how would it work in the modlauncher?
from coremods.
This logic already exists in ModLauncher. If you want a post-processed class to analyze at your leisure, you should be able to set "CLASSDUMP" and trace for that, and it'll dump every class to a temporary directory.
Also
So, you can set the system property -Dmodlauncher.logging.marker.classdump=ACCEPT
to get a dump of classes, I believe.
from coremods.
Can't get it to work, I set the system property but it's not getting through the MarkerManager.exists("CLASSDUMP")
condition.
The main point of this is so users who run into conflicting transformers can send me the class dump which caused my transformer to fail, so I want to make it really easy for them to find what I need.
Just throwing it into the log file is the easiest and what I do now, but a system property that forces a class dump would also work - but in that case I'd rather make it a single property that overrides all the other conditions, so there's no need to deal with log configuration (unless there is a way to enable both the classdump marker and trace logging only via system properties).
from coremods.
It should work, I was testing using the same flag. 🤔
from coremods.
I'm probably doing something wrong... I tried using the system property both in the forge profile in the launcher, and in dev environment. Stepping through the latter returns false on MarkerManager.exists
so it never calls dumpClass
.
property 'modlauncher.logging.marker.classdump', 'ACCEPT'
from coremods.
Along with this, maybe just dumping the transformed bytes into a file could also be an option?
At least that's how i used to double check on my ASM results by dumping them into a file and re-opening them with a decompiler. This might not be very conceptually pleasing, but i do have to say, whenever there was a mistake, it was very obvious from looking at the decompiled class, whereas looking at written-out bytecode instructions might not be too obvious.
Needless to say, i do miss having that option with the newer forge.
Example:
https://github.com/HellFirePvP/AstralSorcery/blob/master/src/main/java/hellfirepvp/astralsorcery/core/AstralTransformer.java#L74-L86
(And yes, i am aware that the implementation isn't exactly cross-platform friendly as the directory path shows, but it's the concept that counts here)
from coremods.
Dumping classes is already a thing. It's supposed to be working. I'll investigate.
from coremods.
Dumping is good for devs, but as I said, I use this as a tool to diagnose errors/conflicts on the user's side - if a transformer fails, I dump instructions into the log and just tell the user to pastebin the log.
I don't know how other devs deal with coremod conflicts when a user issue report has 100+ mods, but my way has already helped me find the conflicting mod within seconds. Since support for multiple JS files was added, my current solution is fine since it's no longer cluttering the main JS file:
- https://github.com/chylex/Better-Sprinting/blob/master/src/main/resources/coremods/utils/helpers.js#L58-L108
- https://github.com/chylex/Better-Sprinting/blob/master/src/main/resources/coremods/utils/constants.js
but it could be nice to have it as a utility.
from coremods.
Having something JS side to print instructions like the OP would be really nice. I have had some cases where my injection was seemingly correct but was failing to merge stack frames when writing the class. I ended up rolling something similar to TraceMethodVIsitor + Textifier in JS to debug that. Whilst general class dumps are nice, being able to log it is also nice.
from coremods.
As was noted before here, there is uility to dump a class' bytes into a file.
This can be found here: https://github.com/cpw/modlauncher/blob/master/src/main/java/cpw/mods/modlauncher/ClassTransformer.java#L122-L150
(Edit: Woops, this was apparently already linked above)
However, as also stated here, this doesn't seem to always function.
So, imo, this should be fixed rather than adding homebrew solutions.
The dumped classes can then be opened by decompilers to both see the code in a somewhat readable form & have access to how its bytecode looks like.
Readable bytecode-only output as dumped by textifier, one crude way can be seen on Stackoverflow would potentially be perferable i suppose..? Though personally i can conduct more information from having the side-by-side view of decompiled readable class + readable bytecode instructions like stuff BytecodeViewer spews out.
from coremods.
Just adding on to this issue, there's a real oddity with SpongeForge running on 1.16 (not nearly relevant) that has some mixins applied and effectively, according to Mixin's dumped class file (through -Dmixin.debug.export=true
) the class should be fine, but apparently there's another transformation going on after Mixin that ends up with a class verify error:
All of the debugging logs are available here: https://gist.github.com/gabizou/beef7061791cdf3fdebb46b810362300
And the post transformed class Mixin can see:
EntityClassification.class.zip
Versus the actual post transformed class:
net.minecraft.entity.EntityClassification.class.zip
The actual classes are different!
BUT, trying to enable mod launcher's final class transformed export is a brain ache and a half because it's not obvious what the actual flags required are (having tried with the flags mentioned above doesn't appear to actually function), let alone having to basically figure out "oh, I need to download that dev log4j file and use the flags: -Dlog4j.configurationFile=foo.xml -Dmodlauncher.logging.marker.classdump=ACCEPT
and then find the dumped directory in your system temp directory is just a bad experience....
What this should really be is a standard property to dump classes to file (Seriously, we should learn from log4shell, just don't let logging configurations be a deterministic behavior change) and just maybe put that folder in the same server directory if possible? Mixin does this out of the box already and that's one of the very well defined properties to help in debugging what's going wrong, but in this case, I spent so much time to find out just how to get the final transformed classes to find out "what's going on"....
from coremods.
Related Issues (20)
- There is no way to remap names
- No way to see the final result of a transform HOT 2
- No way to tell if the coremod is in a developer environment HOT 1
- Cannot instantiate InsnList
- Update ASM to 7
- Include an up to date version of Nashorn HOT 1
- CCE when applying transformers HOT 2
- Allow remapping class names HOT 3
- Some ASM methods are not usable without access to some Java types HOT 2
- Nashorn has been removed for Java 15 HOT 13
- No way to check type of LDC?
- ASMAPI.getSystemPropertyFlag using wrong Boolean conversion HOT 2
- ASMAPI#findFirstInstructionBefore ignores startIndex parameter
- Potential security problem(s) HOT 2
- ClassNode is not on the allowed class list
- Error about fluid flowing block during load on server HOT 4
- Would like a way to create LDC with a float value
- Nashorn exposes java, javax, javafx, com, edu, org packages for scripts by default HOT 7
- loadWithNewGlobal and exit functions
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 coremods.