Added Change ClassFile Versions Plugin
This commit is contained in:
parent
ccd7f278bc
commit
e9f3163e1b
2 changed files with 77 additions and 0 deletions
|
@ -514,6 +514,16 @@ public class BytecodeViewer
|
|||
{
|
||||
BetterJOptionPane.showMessageDialog(viewer, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to alert the user
|
||||
*
|
||||
* @param message the message you need to send
|
||||
*/
|
||||
public static String showInput(String message)
|
||||
{
|
||||
return BetterJOptionPane.showInputDialog(viewer, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alerts the user the program is running something in the background
|
||||
|
@ -561,6 +571,14 @@ public class BytecodeViewer
|
|||
new ExceptionUI(t, author);
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes the title on all of the opened tabs
|
||||
*/
|
||||
public static void updateAllClassNodeByteArrays()
|
||||
{
|
||||
resourceContainers.forEach(ResourceContainer::updateClassNodeBytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes the title on all of the opened tabs
|
||||
*/
|
||||
|
@ -572,6 +590,23 @@ public class BytecodeViewer
|
|||
viewer.refreshTitle();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes the title on all of the opened tabs
|
||||
*/
|
||||
public static void refreshAllTabs()
|
||||
{
|
||||
new Thread(()->
|
||||
{
|
||||
updateBusyStatus(true);
|
||||
for (int i = 0; i < BytecodeViewer.viewer.workPane.tabs.getTabCount(); i++)
|
||||
{
|
||||
ResourceViewer viewer = ((TabbedPane) BytecodeViewer.viewer.workPane.tabs.getTabComponentAt(i)).resource;
|
||||
viewer.refresh(null);
|
||||
}
|
||||
updateBusyStatus(false);
|
||||
}, "Refresh All Tabs").start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the workspace with optional user input required
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
package the.bytecode.club.bytecodeviewer.plugin.preinstalled;
|
||||
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||
import the.bytecode.club.bytecodeviewer.api.Plugin;
|
||||
import the.bytecode.club.bytecodeviewer.api.PluginConsole;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* As long as there are no new opcodes or API changes you can use this plugin to downgrade compiled code
|
||||
*
|
||||
* 1) Import a JDK-11 (or higher) Jar resource inside of BCV
|
||||
* 2) Run this plugin
|
||||
* 3) Export as ZIP, then rename as Jar - Your ClassFiles will now run on JDK-8 (or whatever you selected)
|
||||
*
|
||||
* @author Konloch
|
||||
* @since 07/11/2021
|
||||
*/
|
||||
public class ChangeClassFileVersions extends Plugin
|
||||
{
|
||||
@Override
|
||||
public void execute(ArrayList<ClassNode> classNodeList)
|
||||
{
|
||||
//prompt dialogue for version number
|
||||
// TODO: include a little diagram of what JDK is which number
|
||||
int newVersion = Integer.parseInt(BytecodeViewer.showInput("Class Version Number: (52 = JDK 8)"));
|
||||
|
||||
//update the ClassFile version
|
||||
classNodeList.forEach(classNode -> classNode.version = newVersion);
|
||||
|
||||
//update the the resource byte[]
|
||||
BytecodeViewer.updateAllClassNodeByteArrays();
|
||||
|
||||
//force refresh all tabs
|
||||
BytecodeViewer.refreshAllTabs();
|
||||
|
||||
//alert the changes
|
||||
BytecodeViewer.showMessage("Set all of the class versions to " + newVersion);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue