mirror of
https://github.com/deathmarine/Luyten.git
synced 2024-11-26 22:20:32 +00:00
Added Classloader name dump for debug. Reference #40
This commit is contained in:
parent
16eb43a5c8
commit
92fae89c60
@ -460,6 +460,16 @@ public class MainMenuBar extends JMenuBar {
|
||||
}
|
||||
});
|
||||
helpMenu.add(menuItem);
|
||||
JMenu menuDebug = new JMenu("Debug");
|
||||
menuItem = new JMenuItem("List JVM Classes");
|
||||
menuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
mainWindow.onListLoadedClasses();
|
||||
}
|
||||
});
|
||||
menuDebug.add(menuItem);
|
||||
helpMenu.add(menuDebug);
|
||||
menuItem = new JMenuItem("About");
|
||||
menuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
|
@ -15,6 +15,8 @@ import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
@ -240,6 +242,45 @@ public class MainWindow extends JFrame {
|
||||
}.start();
|
||||
}
|
||||
|
||||
public void onListLoadedClasses(){
|
||||
try {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
ClassLoader myCL = Thread.currentThread().getContextClassLoader();
|
||||
bar.setVisible(true);
|
||||
bar.setIndeterminate(true);
|
||||
while (myCL != null) {
|
||||
sb.append("ClassLoader: " + myCL+"\n");
|
||||
for (Iterator<?> iter = list(myCL); iter.hasNext();) {
|
||||
sb.append("\t" + iter.next() + "\n");
|
||||
}
|
||||
myCL = myCL.getParent();
|
||||
}
|
||||
MainWindow.this.getModel().show("Debug", sb.toString());
|
||||
} finally {
|
||||
bar.setIndeterminate(false);
|
||||
bar.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static Iterator<?> list(ClassLoader CL){
|
||||
Class<?> CL_class = CL.getClass();
|
||||
while (CL_class != java.lang.ClassLoader.class) {
|
||||
CL_class = CL_class.getSuperclass();
|
||||
}
|
||||
java.lang.reflect.Field ClassLoader_classes_field;
|
||||
try {
|
||||
ClassLoader_classes_field = CL_class
|
||||
.getDeclaredField("classes");
|
||||
ClassLoader_classes_field.setAccessible(true);
|
||||
Vector<?> classes = (Vector<?>) ClassLoader_classes_field.get(CL);
|
||||
return classes.iterator();
|
||||
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getLegalStr() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
try {
|
||||
|
@ -141,8 +141,12 @@ public class Model extends JSplitPane {
|
||||
}
|
||||
|
||||
public void showLegal(String legalStr) {
|
||||
OpenFile open = new OpenFile("Legal", "*/Legal", theme, mainWindow);
|
||||
open.setContent(legalStr);
|
||||
show("Legal", legalStr);
|
||||
}
|
||||
|
||||
public void show(String name, String contents) {
|
||||
OpenFile open = new OpenFile(name, "*/"+name, theme, mainWindow);
|
||||
open.setContent(contents);
|
||||
hmap.add(open);
|
||||
addOrSwitchToTab(open);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user