Uses 1311K of libraries. Click here for Pure Java version (2734L/16K).
!include once #1019934 // BCEL import org.apache.bcel.classfile.Attribute; import org.apache.bcel.classfile.SourceFile; import org.apache.bcel.generic.*; svoid changeJavaVersionInClassFile(File classFile, int newMajor, int newMinor) ctex { JavaClass c = new ClassParser(classFile.getPath(), classFile.getName()).parse(); int major = c.getMajor(), minor = c.getMinor(); print("Current Java version of " + classFile + ": " + major + "." + minor); if (major == newMajor && minor == newMinor) ret; print(" Patching to " + newMajor + "." + newMinor); ClassGen g = new ClassGen(c); g.setMajor(newMajor); g.setMinor(newMinor); c = g.getJavaClass(); c.dump(classFile); // overwrite! print(" Done"); }
Began life as a copy of #1004069
download show line numbers debug dex old transpilations
Travelled to 5 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1030868 |
Snippet name: | changeJavaVersionInClassFile |
Eternal ID of this version: | #1030868/4 |
Text MD5: | f35a5bc55dd1e9359d273af9df82d3b4 |
Transpilation MD5: | b0e2b5d833a0b6dae56f22383df37103 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-04-04 20:38:23 |
Source code size: | 738 bytes / 20 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 186 / 264 |
Version history: | 3 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |