47 lines
1.9 KiB
Java
47 lines
1.9 KiB
Java
import java.lang.reflect.*;
|
|
import java.util.*;
|
|
|
|
public class TestCUPSPrinter {
|
|
public static void main(String[] args) throws Exception {
|
|
System.out.println("=== Testing CUPSPrinter via Reflection ===");
|
|
|
|
try {
|
|
// Load CUPSPrinter class
|
|
Class<?> cupsPrinterClass = Class.forName("sun.print.CUPSPrinter");
|
|
System.out.println("OK: Loaded CUPSPrinter class");
|
|
|
|
// Get constructor
|
|
Constructor<?> constructor = cupsPrinterClass.getDeclaredConstructor(String.class);
|
|
constructor.setAccessible(true);
|
|
|
|
// Try to create instance with a printer name
|
|
Object cupsPrinter = constructor.newInstance("Brother_HL_L2370DN_series");
|
|
System.out.println("OK: Created CUPSPrinter instance");
|
|
|
|
// Try to call methods
|
|
Method[] methods = cupsPrinterClass.getDeclaredMethods();
|
|
System.out.println("\nAvailable methods:");
|
|
for (Method m : methods) {
|
|
System.out.println(" " + m.getName() + "()");
|
|
}
|
|
|
|
// Look for specific methods
|
|
for (Method m : methods) {
|
|
if (m.getName().contains("get") || m.getName().contains("is")) {
|
|
m.setAccessible(true);
|
|
try {
|
|
Object result = m.invoke(cupsPrinter);
|
|
System.out.println(" " + m.getName() + "() = " + result);
|
|
} catch (Exception e) {
|
|
// Ignore methods that need parameters
|
|
}
|
|
}
|
|
}
|
|
|
|
} catch (ClassNotFoundException e) {
|
|
System.out.println("ERROR: CUPSPrinter class not found");
|
|
System.out.println("Classpath: " + System.getProperty("java.class.path"));
|
|
}
|
|
}
|
|
}
|