package bugverif; import com.sun.javafx.css.StyleableProperty; import java.io.File; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.util.List; import javafx.beans.value.WritableValue; import javafx.scene.Node; public class RT18097 { public static void main(String[] args) { File folder1 = new File("C://work//repos//all_rt"); recursiveSearch(folder1); } private static void workWithTargetFile(File file) throws MalformedURLException, IllegalAccessException, InstantiationException, IllegalArgumentException, InvocationTargetException { if (file.getAbsolutePath().contains("\\src\\")) { URL[] addr = new URL[1]; addr[0] = file.toURL(); ClassLoader loader = new URLClassLoader(addr); String className = file.getAbsolutePath().substring(file.getAbsolutePath().indexOf("src") + 4, file.getAbsolutePath().length() - 5).replace('\\', '.'); try { Class someClass = loader.loadClass(className); //System.out.println("Class found : " + className); Method[] methodsArray = someClass.getDeclaredMethods(); for (Method m : methodsArray) { //System.out.println("Method : " + m); if (m.getReturnType().equals(List.class) && m.getName().equalsIgnoreCase("impl_CSS_STYLEABLES") && Modifier.isStatic(m.getModifiers())) { //System.out.println("Found one needed method : " + m); for (StyleableProperty styleable : (List) m.invoke(null)) { Boolean error = false; WritableValue writable = null; try { writable = styleable.getWritableValue((Node) someClass.newInstance()); } catch (Exception e) { //System.out.println("Error happened with instantiation : " + someClass); error = true; } if (!error) { Object defaultValue = writable.getValue(); Object value = styleable.getInitialValue((Node) someClass.newInstance()); Boolean valid = defaultValue == null ? value == null : defaultValue.equals(value); if ((defaultValue instanceof Number) && (value instanceof Number)) { defaultValue = ((Number) defaultValue).doubleValue(); value = ((Number) value).doubleValue(); valid = Math.abs((double) defaultValue - (double) value) < 0.00001; } if ((defaultValue instanceof Double[]) && (value instanceof Double[])) { Double[] defaultValuesArray = (Double[]) defaultValue; Double[] valuesArray = (Double[]) value; valid = true; for (int i = 0; i < Math.min(defaultValuesArray.length, valuesArray.length); i++) { valid = valid && (Math.abs(defaultValuesArray[i] - valuesArray[i]) < 0.00001); } valid = valid && (defaultValuesArray.length == valuesArray.length); if (!valid) { System.out.println("CLASS : " + someClass + "; STYLEABLE : " + styleable + "; DEFAULT_VALUE : " + defaultValuesArray + "; VALUE : " + valuesArray); } } else { //System.out.println("Check result : " + valid); if (!valid) { System.out.println("CLASS : " + someClass + "; STYLEABLE : " + styleable + "; DEFAULT_VALUE : " + defaultValue + "; VALUE : " + value); } } } } } } } catch (ClassNotFoundException ex) { //System.out.println("Class not found : " + className); } } } private static void parseTargetDirectory(File directory) { if (directory.isDirectory()) { for (File subFile : directory.listFiles()) { if (subFile.isFile() && subFile.getName().endsWith(".java")) { try { workWithTargetFile(subFile); } catch (Exception e) { System.out.println("Exception : " + e); } } else { parseTargetDirectory(subFile); } } } } private static void recursiveSearch(File directory) { if (directory.isDirectory()) { //System.out.println(directory.getPath()); if (directory.getPath().endsWith("javafx\\scene")) { parseTargetDirectory(directory); } for (File subFile : directory.listFiles()) { recursiveSearch(subFile); } } } }