void () { Pattern defaultValueJavaDoc = Pattern.compile("^.*\\*\\s*@defaultValue\\s*(.+)\\s*$"); Pattern fieldDecl = Pattern.compile("^.*\\s(\\w+)\\s*(=.*|;)\\s*$"); Pattern methodDecl = Pattern.compile("^.*\\s(\\w+)\\s*\\(\\).*$"); Pattern propertyDecl = Pattern.compile("^.*Property\\S*\\s+(\\w+)\\s*=\\s*(.+)[;{].*$"); Map<String, String> props = new TreeMap<>(); try (final ZipInputStream zip = new ZipInputStream(new FileInputStream(SOURCE_PATH))) { byte[] buffer = new byte[1 << 16]; for (ZipEntry ze = zip.getNextEntry(); ze != null; ze = zip.getNextEntry()) { final String eName = ze.getName(); if (!ze.isDirectory() && eName.endsWith(".java") && eName.startsWith("javafx")) { String className = eName.substring(0, eName.lastIndexOf('.')).replace('/', '.'); if (ourSourceClasses.contains(className)) { StringBuilder text = new StringBuilder(); int len; while ((len = zip.read(buffer)) > 0) { String str = new String(buffer, 0, len, StandardCharsets.UTF_8); text.append(str); } String[] lines = text.toString().split("\n"); int state = 0; String name = null; String value = null; for (String s : lines) { Matcher m; m = propertyDecl.matcher(s); if (m.matches()) { name = m.group(1); value = m.group(2); if (!"null".equals(value)) { props.put(className + "#" + name, value); } } switch (state) { case 0 -> { m = defaultValueJavaDoc.matcher(s); if (m.matches()) { state = 1; value = m.group(1); } } case 1 -> { if (s.contains("*/")) state = 2; } case 2 -> { if (!s.trim().isEmpty()) { state = 0; m = fieldDecl.matcher(s); if (m.matches()) { name = m.group(1); } else { m = methodDecl.matcher(s); if (m.matches()) { name = m.group(1); } } if (name != null && value != null && !"null".equals(value)) { props.put(className + "#" + name, value); } name = value = null; } } } } } } } } catch (IOException e) { System.err.println("Failed to read sources " + e); } System.out.println("--- Default values collected from JavaDoc and declarations. To be reviewed and manually edited ---"); props.forEach((n, v) -> System.out.println(n + "=" + v)); } private static class DefaultValue { private final String myValueText; private final String myDeclaringClass; DefaultValue(@NotNull Object value, @NotNull String declaringClass) { myValueText = String.valueOf(value); myDeclaringClass = declaringClass; } public String getDeclaringClass() { return myDeclaringClass; } public String getValueText() { return myValueText; } @Override public String toString() { return myValueText; } } }