< prev index next >

make/langtools/src/classes/build/tools/symbolgenerator/CreateSymbols.java

Print this page
rev 59492 : [mq]: 8244763-create-symbols
rev 59493 : imported patch 8244763-v2

*** 29,38 **** --- 29,39 ---- .ModuleHeaderDescription .ProvidesDescription; import build.tools.symbolgenerator.CreateSymbols .ModuleHeaderDescription .RequiresDescription; + import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.BufferedOutputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream;
*** 41,50 **** --- 42,52 ---- import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.StringWriter; import java.io.Writer; + import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.FileVisitResult; import java.nio.file.FileVisitor; import java.nio.file.Path; import java.nio.file.Paths;
*** 218,228 **** @SuppressWarnings("unchecked") public void createSymbols(String ctDescriptionFileExtra, String ctDescriptionFile, String ctSymLocation, long timestamp, String currentVersion, String systemModules) throws IOException { LoadDescriptions data = load(ctDescriptionFileExtra != null ? Paths.get(ctDescriptionFileExtra) : null, ! Paths.get(ctDescriptionFile), null); splitHeaders(data.classes); Map<String, Map<Character, String>> package2Version2Module = new HashMap<>(); Map<String, Set<FileData>> directory2FileData = new TreeMap<>(); --- 220,230 ---- @SuppressWarnings("unchecked") public void createSymbols(String ctDescriptionFileExtra, String ctDescriptionFile, String ctSymLocation, long timestamp, String currentVersion, String systemModules) throws IOException { LoadDescriptions data = load(ctDescriptionFileExtra != null ? Paths.get(ctDescriptionFileExtra) : null, ! Paths.get(ctDescriptionFile)); splitHeaders(data.classes); Map<String, Map<Character, String>> package2Version2Module = new HashMap<>(); Map<String, Set<FileData>> directory2FileData = new TreeMap<>();
*** 301,311 **** return ze; } public static String EXTENSION = ".sig"; ! LoadDescriptions load(Path ctDescriptionWithExtraContent, Path ctDescriptionOpen, String deletePlatform) throws IOException { Map<String, PlatformInput> platforms = new LinkedHashMap<>(); if (ctDescriptionWithExtraContent != null && Files.isRegularFile(ctDescriptionWithExtraContent)) { try (LineBasedReader reader = new LineBasedReader(ctDescriptionWithExtraContent)) { while (reader.hasNext()) { --- 303,313 ---- return ze; } public static String EXTENSION = ".sig"; ! LoadDescriptions load(Path ctDescriptionWithExtraContent, Path ctDescriptionOpen) throws IOException { Map<String, PlatformInput> platforms = new LinkedHashMap<>(); if (ctDescriptionWithExtraContent != null && Files.isRegularFile(ctDescriptionWithExtraContent)) { try (LineBasedReader reader = new LineBasedReader(ctDescriptionWithExtraContent)) { while (reader.hasNext()) {
*** 315,325 **** reader.moveNext(); break; case "platform": PlatformInput platform = PlatformInput.load(ctDescriptionWithExtraContent, reader); - if (!platform.version.equals(deletePlatform)) platforms.put(platform.version, platform); reader.moveNext(); break; default: throw new IllegalStateException("Unknown key: " + reader.lineKey); --- 317,326 ----
*** 334,350 **** while (reader.hasNext()) { switch (reader.lineKey) { case "generate": String[] platformsAttr = reader.attributes.get("platforms").split(":"); generatePlatforms = new HashSet<>(List.of(platformsAttr)); - generatePlatforms.remove(deletePlatform); reader.moveNext(); break; case "platform": PlatformInput platform = PlatformInput.load(ctDescriptionOpen, reader); ! if (!platform.version.equals(deletePlatform) && ! !platforms.containsKey(platform.version)) platforms.put(platform.version, platform); reader.moveNext(); break; default: throw new IllegalStateException("Unknown key: " + reader.lineKey); --- 335,349 ---- while (reader.hasNext()) { switch (reader.lineKey) { case "generate": String[] platformsAttr = reader.attributes.get("platforms").split(":"); generatePlatforms = new HashSet<>(List.of(platformsAttr)); reader.moveNext(); break; case "platform": PlatformInput platform = PlatformInput.load(ctDescriptionOpen, reader); ! if (!platforms.containsKey(platform.version)) platforms.put(platform.version, platform); reader.moveNext(); break; default: throw new IllegalStateException("Unknown key: " + reader.lineKey);
*** 406,476 **** } } ClassList result = new ClassList(); ! for (ClassDescription desc : classes.values()) { Iterator<ClassHeaderDescription> chdIt = desc.header.iterator(); while (chdIt.hasNext()) { ClassHeaderDescription chd = chdIt.next(); ! chd.versions = reduce(chd.versions, generatePlatforms); ! if (chd.versions.isEmpty()) chdIt.remove(); } if (desc.header.isEmpty()) { continue; } Iterator<MethodDescription> methodIt = desc.methods.iterator(); while (methodIt.hasNext()) { MethodDescription method = methodIt.next(); ! method.versions = reduce(method.versions, generatePlatforms); if (method.versions.isEmpty()) methodIt.remove(); } Iterator<FieldDescription> fieldIt = desc.fields.iterator(); while (fieldIt.hasNext()) { FieldDescription field = fieldIt.next(); ! field.versions = reduce(field.versions, generatePlatforms); if (field.versions.isEmpty()) fieldIt.remove(); } - - result.add(desc); } ! Map<String, ModuleDescription> moduleList = new HashMap<>(); ! ! for (ModuleDescription desc : modules.values()) { Iterator<ModuleHeaderDescription> mhdIt = desc.header.iterator(); while (mhdIt.hasNext()) { ModuleHeaderDescription mhd = mhdIt.next(); ! mhd.versions = reduce(mhd.versions, generatePlatforms); if (mhd.versions.isEmpty()) mhdIt.remove(); } if (desc.header.isEmpty()) { continue; } - - moduleList.put(desc.name, desc); } - - return new LoadDescriptions(result, - moduleList, - new ArrayList<>(platforms.values())); } static final class LoadDescriptions { public final ClassList classes; public final Map<String, ModuleDescription> modules; --- 405,477 ---- } } ClassList result = new ClassList(); ! classes.values().forEach(result::add); ! return new LoadDescriptions(result, ! modules, ! new ArrayList<>(platforms.values())); ! } ! ! private static void removeVersion(LoadDescriptions load, String deletePlatform) { ! for (Iterator<ClassDescription> it = load.classes.iterator(); it.hasNext();) { ! ClassDescription desc = it.next(); Iterator<ClassHeaderDescription> chdIt = desc.header.iterator(); while (chdIt.hasNext()) { ClassHeaderDescription chd = chdIt.next(); ! chd.versions = removeVersion(chd.versions, deletePlatform); ! if (chd.versions.isEmpty()) { chdIt.remove(); } + } if (desc.header.isEmpty()) { + it.remove(); continue; } Iterator<MethodDescription> methodIt = desc.methods.iterator(); while (methodIt.hasNext()) { MethodDescription method = methodIt.next(); ! method.versions = removeVersion(method.versions, deletePlatform); if (method.versions.isEmpty()) methodIt.remove(); } Iterator<FieldDescription> fieldIt = desc.fields.iterator(); while (fieldIt.hasNext()) { FieldDescription field = fieldIt.next(); ! field.versions = removeVersion(field.versions, deletePlatform); if (field.versions.isEmpty()) fieldIt.remove(); } } ! for (Iterator<ModuleDescription> it = load.modules.values().iterator(); it.hasNext();) { ! ModuleDescription desc = it.next(); Iterator<ModuleHeaderDescription> mhdIt = desc.header.iterator(); while (mhdIt.hasNext()) { ModuleHeaderDescription mhd = mhdIt.next(); ! mhd.versions = removeVersion(mhd.versions, deletePlatform); if (mhd.versions.isEmpty()) mhdIt.remove(); } if (desc.header.isEmpty()) { + it.remove(); continue; } } } static final class LoadDescriptions { public final ClassList classes; public final Map<String, ModuleDescription> modules;
*** 548,557 **** --- 549,569 ---- } } return sb.toString(); } + private static String removeVersion(String original, String remove) { + StringBuilder sb = new StringBuilder(); + + for (char v : original.toCharArray()) { + if (v != remove.charAt(0)) { + sb.append(v); + } + } + return sb.toString(); + } + private static class PlatformInput { public final String version; public final String basePlatform; public final List<String> files; public final Path ctDescription;
*** 1256,1294 **** String[] args) throws IOException { ClassList classes = new ClassList(); Map<String, ModuleDescription> modules = new HashMap<>(); for (VersionDescription desc : versions) { ! List<byte[]> classFileData = new ArrayList<>(); ! ! try (BufferedReader descIn = ! Files.newBufferedReader(Paths.get(desc.classes))) { ! String line; ! while ((line = descIn.readLine()) != null) { ! ByteArrayOutputStream data = new ByteArrayOutputStream(); ! for (int i = 0; i < line.length(); i += 2) { ! String hex = line.substring(i, i + 2); ! data.write(Integer.parseInt(hex, 16)); ! } ! classFileData.add(data.toByteArray()); ! } ! } catch (IOException ex) { ! throw new IllegalStateException(ex); ! } ! loadVersionClasses(classes, modules, classFileData, excludesIncludes, desc.version); } List<PlatformInput> platforms = versions.stream() .map(desc -> new PlatformInput(null, desc.version, desc.primaryBaseline, null)) .collect(Collectors.toList()); ! dumpDescriptions(classes, modules, platforms, descDest.resolve("symbols"), args); } //where: private static final String DO_NO_MODIFY = "#\n" + "# Copyright (c) {YEAR}, Oracle and/or its affiliates. All rights reserved.\n" + --- 1268,1291 ---- String[] args) throws IOException { ClassList classes = new ClassList(); Map<String, ModuleDescription> modules = new HashMap<>(); for (VersionDescription desc : versions) { ! Iterable<byte[]> classFileData = loadClassData(desc.classes); ! loadVersionClasses(classes, modules, classFileData, excludesIncludes, desc.version, null); } List<PlatformInput> platforms = versions.stream() .map(desc -> new PlatformInput(null, desc.version, desc.primaryBaseline, null)) .collect(Collectors.toList()); ! dumpDescriptions(classes, modules, platforms, Set.of(), descDest.resolve("symbols"), args); } //where: private static final String DO_NO_MODIFY = "#\n" + "# Copyright (c) {YEAR}, Oracle and/or its affiliates. All rights reserved.\n" +
*** 1317,1331 **** "# ##########################################################\n" + "# ### THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. ###\n" + "# ##########################################################\n" + "#\n"; private void loadVersionClasses(ClassList classes, Map<String, ModuleDescription> modules, Iterable<byte[]> classData, ExcludeIncludeList excludesIncludes, ! String version) { Map<String, ModuleDescription> currentVersionModules = new HashMap<>(); for (byte[] classFileData : classData) { try (InputStream in = new ByteArrayInputStream(classFileData)) { --- 1314,1350 ---- "# ##########################################################\n" + "# ### THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. ###\n" + "# ##########################################################\n" + "#\n"; + private Iterable<byte[]> loadClassData(String path) { + List<byte[]> classFileData = new ArrayList<>(); + + try (BufferedReader descIn = + Files.newBufferedReader(Paths.get(path))) { + String line; + while ((line = descIn.readLine()) != null) { + ByteArrayOutputStream data = new ByteArrayOutputStream(); + for (int i = 0; i < line.length(); i += 2) { + String hex = line.substring(i, i + 2); + data.write(Integer.parseInt(hex, 16)); + } + classFileData.add(data.toByteArray()); + } + } catch (IOException ex) { + throw new IllegalStateException(ex); + } + + return classFileData; + } + private void loadVersionClasses(ClassList classes, Map<String, ModuleDescription> modules, Iterable<byte[]> classData, ExcludeIncludeList excludesIncludes, ! String version, ! String baseline) { Map<String, ModuleDescription> currentVersionModules = new HashMap<>(); for (byte[] classFileData : classData) { try (InputStream in = new ByteArrayInputStream(classFileData)) {
*** 1445,1460 **** } ClassDescription existing = classes.find(clazz.name, true); if (existing != null) { ! addClassHeader(existing, header, version); for (MethodDescription currentMethod : clazz.methods) { ! addMethod(existing, currentMethod, version); } for (FieldDescription currentField : clazz.fields) { ! addField(existing, currentField, version); } } else { classes.add(clazz); } } --- 1464,1479 ---- } ClassDescription existing = classes.find(clazz.name, true); if (existing != null) { ! addClassHeader(existing, header, version, baseline); for (MethodDescription currentMethod : clazz.methods) { ! addMethod(existing, currentMethod, version, baseline); } for (FieldDescription currentField : clazz.fields) { ! addField(existing, currentField, version, baseline); } } else { classes.add(clazz); } }
*** 1487,1496 **** --- 1506,1516 ---- "Lsun/Proprietary+Annotation;"; private void dumpDescriptions(ClassList classes, Map<String, ModuleDescription> modules, List<PlatformInput> versions, + Set<String> forceWriteVersions, Path ctDescriptionFile, String[] args) throws IOException { classes.sort(); Map<String, String> package2Modules = new HashMap<>();
*** 1553,1563 **** Map<PlatformInput, List<String>> outputFiles = new LinkedHashMap<>(); for (PlatformInput desc : versions) { List<String> files = desc.files; ! if (files == null) { files = new ArrayList<>(); for (Entry<String, List<ClassDescription>> e : module2Classes.entrySet()) { StringWriter data = new StringWriter(); ModuleDescription module = modules.get(e.getKey()); --- 1573,1583 ---- Map<PlatformInput, List<String>> outputFiles = new LinkedHashMap<>(); for (PlatformInput desc : versions) { List<String> files = desc.files; ! if (files == null || forceWriteVersions.contains(desc.version)) { files = new ArrayList<>(); for (Entry<String, List<ClassDescription>> e : module2Classes.entrySet()) { StringWriter data = new StringWriter(); ModuleDescription module = modules.get(e.getKey());
*** 1571,1584 **** Path f = ctDescriptionFile.getParent().resolve(fileName); String dataString = data.toString(); if (!dataString.isEmpty()) { ! try (Writer out = Files.newBufferedWriter(f)) { ! out.append(DO_NO_MODIFY.replace("{YEAR}", String.valueOf(year))); out.write(dataString); } files.add(f.getFileName().toString()); } } } --- 1591,1628 ---- Path f = ctDescriptionFile.getParent().resolve(fileName); String dataString = data.toString(); if (!dataString.isEmpty()) { ! String existingYear = null; ! boolean hasChange = true; ! if (Files.isReadable(f)) { ! String oldContent = Files.readString(f, StandardCharsets.UTF_8); ! int yearPos = DO_NO_MODIFY.indexOf("{YEAR}"); ! String headerPattern = ! Pattern.quote(DO_NO_MODIFY.substring(0, yearPos)) + ! "([0-9]+)(, [0-9]+)?" + ! Pattern.quote(DO_NO_MODIFY.substring(yearPos + "{YEAR}".length())); ! String pattern = headerPattern + ! Pattern.quote(dataString); ! Matcher m = Pattern.compile(pattern, Pattern.MULTILINE).matcher(oldContent); ! if (m.matches()) { ! hasChange = false; ! } else { ! m = Pattern.compile(headerPattern).matcher(oldContent); ! if (m.find()) { ! existingYear = m.group(1); ! } ! } ! } ! if (hasChange) { ! try (Writer out = Files.newBufferedWriter(f, StandardCharsets.UTF_8)) { ! String yearSpec = (existingYear != null ? existingYear + ", " : "") + String.valueOf(year); ! out.append(DO_NO_MODIFY.replace("{YEAR}", yearSpec)); out.write(dataString); } + } files.add(f.getFileName().toString()); } } }
*** 1615,1658 **** .append("\n"); } } } ! public void createIncrementalBaseLine(String ctDescriptionFile, String excludeFile, String[] args) throws IOException { - String specVersion = System.getProperty("java.specification.version"); String currentVersion = ! Integer.toString(Integer.parseInt(specVersion), Character.MAX_RADIX); ! currentVersion = currentVersion.toUpperCase(Locale.ROOT); Path ctDescriptionPath = Paths.get(ctDescriptionFile).toAbsolutePath(); ! LoadDescriptions data = load(null, ctDescriptionPath, currentVersion); ClassList classes = data.classes; Map<String, ModuleDescription> modules = data.modules; List<PlatformInput> versions = data.versions; ExcludeIncludeList excludeList = ExcludeIncludeList.create(excludeFile); ! Iterable<byte[]> classBytes = dumpCurrentClasses(); ! loadVersionClasses(classes, modules, classBytes, excludeList, currentVersion); ! String baseline; ! if (versions.isEmpty()) { ! baseline = null; } else { ! baseline = versions.stream() .sorted((v1, v2) -> v2.version.compareTo(v1.version)) .findFirst() .get() .version; } ! ! versions.add(new PlatformInput(null, currentVersion, baseline, null)); ! dumpDescriptions(classes, modules, versions, ctDescriptionPath, args); } private List<byte[]> dumpCurrentClasses() throws IOException { JavacTool tool = JavacTool.create(); Context ctx = new Context(); --- 1659,1751 ---- .append("\n"); } } } ! private void incrementalUpdate(String ctDescriptionFile, String excludeFile, + String platformVersion, + Iterable<byte[]> classBytes, + Function<LoadDescriptions, String> baseline, String[] args) throws IOException { String currentVersion = ! Integer.toString(Integer.parseInt(platformVersion), Character.MAX_RADIX); ! String version = currentVersion.toUpperCase(Locale.ROOT); Path ctDescriptionPath = Paths.get(ctDescriptionFile).toAbsolutePath(); ! LoadDescriptions data = load(null, ctDescriptionPath); ClassList classes = data.classes; Map<String, ModuleDescription> modules = data.modules; List<PlatformInput> versions = data.versions; ExcludeIncludeList excludeList = ExcludeIncludeList.create(excludeFile); ! loadVersionClasses(classes, modules, classBytes, excludeList, "$", version); ! ! removeVersion(data, version); ! ! for (ModuleDescription md : data.modules.values()) { ! for (ModuleHeaderDescription header : md.header) { ! header.versions = header.versions.replace("$", version); ! } ! } ! ! for (ClassDescription clazzDesc : data.classes) { ! for (ClassHeaderDescription header : clazzDesc.header) { ! header.versions = header.versions.replace("$", version); ! } ! for (MethodDescription method : clazzDesc.methods) { ! method.versions = method.versions.replace("$", version); ! } ! for (FieldDescription field : clazzDesc.fields) { ! field.versions = field.versions.replace("$", version); ! } ! } ! ! if (versions.stream().noneMatch(inp -> version.equals(inp.version))) { ! versions.add(new PlatformInput(null, version, baseline.apply(data), null)); ! } ! ! Set<String> writeVersions = new HashSet<>(); ! writeVersions.add(version); ! ! //re-write all platforms that have version as their basline: ! versions.stream() ! .filter(inp -> version.equals(inp.basePlatform)) ! .map(inp -> inp.version) ! .forEach(writeVersions::add); ! dumpDescriptions(classes, modules, versions, writeVersions, ctDescriptionPath, args); ! } ! ! public void createIncrementalBaseLineFromDataFile(String ctDescriptionFile, ! String excludeFile, ! String version, ! String dataFile, ! String baseline, ! String[] args) throws IOException { ! incrementalUpdate(ctDescriptionFile, excludeFile, version, loadClassData(dataFile), x -> baseline, args); ! } ! public void createIncrementalBaseLine(String ctDescriptionFile, ! String excludeFile, ! String[] args) throws IOException { ! String specVersion = System.getProperty("java.specification.version"); ! Iterable<byte[]> classBytes = dumpCurrentClasses(); ! Function<LoadDescriptions, String> baseline = data -> { ! if (data.versions.isEmpty()) { ! return null; } else { ! return data.versions.stream() .sorted((v1, v2) -> v2.version.compareTo(v1.version)) .findFirst() .get() .version; } ! }; ! incrementalUpdate(ctDescriptionFile, excludeFile, specVersion, classBytes, baseline, args); } private List<byte[]> dumpCurrentClasses() throws IOException { JavacTool tool = JavacTool.create(); Context ctx = new Context();
*** 1742,1752 **** clazzDesc = new ClassDescription(); clazzDesc.name = cf.getName(); classes.add(clazzDesc); } ! addClassHeader(clazzDesc, headerDesc, version); for (Method m : cf.methods) { if (!include(m.access_flags.flags)) continue; MethodDescription methDesc = new MethodDescription(); --- 1835,1845 ---- clazzDesc = new ClassDescription(); clazzDesc.name = cf.getName(); classes.add(clazzDesc); } ! addClassHeader(clazzDesc, headerDesc, version, null); for (Method m : cf.methods) { if (!include(m.access_flags.flags)) continue; MethodDescription methDesc = new MethodDescription();
*** 1754,1764 **** methDesc.name = m.getName(cf.constant_pool); methDesc.descriptor = m.descriptor.getValue(cf.constant_pool); for (Attribute attr : m.attributes) { readAttribute(cf, methDesc, attr); } ! addMethod(clazzDesc, methDesc, version); } for (Field f : cf.fields) { if (!include(f.access_flags.flags)) continue; FieldDescription fieldDesc = new FieldDescription(); --- 1847,1857 ---- methDesc.name = m.getName(cf.constant_pool); methDesc.descriptor = m.descriptor.getValue(cf.constant_pool); for (Attribute attr : m.attributes) { readAttribute(cf, methDesc, attr); } ! addMethod(clazzDesc, methDesc, version, null); } for (Field f : cf.fields) { if (!include(f.access_flags.flags)) continue; FieldDescription fieldDesc = new FieldDescription();
*** 1766,1776 **** fieldDesc.name = f.getName(cf.constant_pool); fieldDesc.descriptor = f.descriptor.getValue(cf.constant_pool); for (Attribute attr : f.attributes) { readAttribute(cf, fieldDesc, attr); } ! addField(clazzDesc, fieldDesc, version); } } private void inspectModuleInfoClassFile(InputStream in, Map<String, ModuleDescription> modules, --- 1859,1869 ---- fieldDesc.name = f.getName(cf.constant_pool); fieldDesc.descriptor = f.descriptor.getValue(cf.constant_pool); for (Attribute attr : f.attributes) { readAttribute(cf, fieldDesc, attr); } ! addField(clazzDesc, fieldDesc, version, null); } } private void inspectModuleInfoClassFile(InputStream in, Map<String, ModuleDescription> modules,
*** 1825,1839 **** private boolean include(int accessFlags) { return (accessFlags & (AccessFlags.ACC_PUBLIC | AccessFlags.ACC_PROTECTED)) != 0; } ! private void addClassHeader(ClassDescription clazzDesc, ClassHeaderDescription headerDesc, String version) { //normalize: boolean existed = false; for (ClassHeaderDescription existing : clazzDesc.header) { ! if (existing.equals(headerDesc)) { headerDesc = existing; existed = true; } } --- 1918,1932 ---- private boolean include(int accessFlags) { return (accessFlags & (AccessFlags.ACC_PUBLIC | AccessFlags.ACC_PROTECTED)) != 0; } ! private void addClassHeader(ClassDescription clazzDesc, ClassHeaderDescription headerDesc, String version, String baseline) { //normalize: boolean existed = false; for (ClassHeaderDescription existing : clazzDesc.header) { ! if (existing.equals(headerDesc) && (!existed || (baseline != null && existing.versions.contains(baseline)))) { headerDesc = existing; existed = true; } }
*** 1865,1897 **** if (!existed) { clazzDesc.header.add(headerDesc); } } ! private void addMethod(ClassDescription clazzDesc, MethodDescription methDesc, String version) { //normalize: boolean methodExisted = false; for (MethodDescription existing : clazzDesc.methods) { ! if (existing.equals(methDesc)) { methodExisted = true; methDesc = existing; - break; } } methDesc.versions += version; if (!methodExisted) { clazzDesc.methods.add(methDesc); } } ! private void addField(ClassDescription clazzDesc, FieldDescription fieldDesc, String version) { boolean fieldExisted = false; for (FieldDescription existing : clazzDesc.fields) { ! if (existing.equals(fieldDesc)) { fieldExisted = true; fieldDesc = existing; - break; } } fieldDesc.versions += version; if (!fieldExisted) { clazzDesc.fields.add(fieldDesc); --- 1958,1988 ---- if (!existed) { clazzDesc.header.add(headerDesc); } } ! private void addMethod(ClassDescription clazzDesc, MethodDescription methDesc, String version, String baseline) { //normalize: boolean methodExisted = false; for (MethodDescription existing : clazzDesc.methods) { ! if (existing.equals(methDesc) && (!methodExisted || (baseline != null && existing.versions.contains(baseline)))) { methodExisted = true; methDesc = existing; } } methDesc.versions += version; if (!methodExisted) { clazzDesc.methods.add(methDesc); } } ! private void addField(ClassDescription clazzDesc, FieldDescription fieldDesc, String version, String baseline) { boolean fieldExisted = false; for (FieldDescription existing : clazzDesc.fields) { ! if (existing.equals(fieldDesc) && (!fieldExisted || (baseline != null && existing.versions.contains(baseline)))) { fieldExisted = true; fieldDesc = existing; } } fieldDesc.versions += version; if (!fieldExisted) { clazzDesc.fields.add(fieldDesc);
*** 2296,2305 **** --- 2387,2397 ---- (baselineVersion != null && versions.contains(baselineVersion)); } static abstract class FeatureDescription { + int flagsNormalization = ~0; int flags; boolean deprecated; String signature; String versions = ""; List<AnnotationDescription> classAnnotations;
*** 2360,2370 **** public abstract boolean read(LineBasedReader reader) throws IOException; @Override public int hashCode() { int hash = 3; ! hash = 89 * hash + this.flags; hash = 89 * hash + (this.deprecated ? 1 : 0); hash = 89 * hash + Objects.hashCode(this.signature); hash = 89 * hash + listHashCode(this.classAnnotations); hash = 89 * hash + listHashCode(this.runtimeAnnotations); return hash; --- 2452,2462 ---- public abstract boolean read(LineBasedReader reader) throws IOException; @Override public int hashCode() { int hash = 3; ! hash = 89 * hash + (this.flags & flagsNormalization); hash = 89 * hash + (this.deprecated ? 1 : 0); hash = 89 * hash + Objects.hashCode(this.signature); hash = 89 * hash + listHashCode(this.classAnnotations); hash = 89 * hash + listHashCode(this.runtimeAnnotations); return hash;
*** 2377,2387 **** } if (getClass() != obj.getClass()) { return false; } final FeatureDescription other = (FeatureDescription) obj; ! if (this.flags != other.flags) { return false; } if (this.deprecated != other.deprecated) { return false; } --- 2469,2479 ---- } if (getClass() != obj.getClass()) { return false; } final FeatureDescription other = (FeatureDescription) obj; ! if ((this.flags & flagsNormalization) != (other.flags & flagsNormalization)) { return false; } if (this.deprecated != other.deprecated) { return false; }
*** 3029,3045 **** --- 3121,3142 ---- } } static class MethodDescription extends FeatureDescription { + static int METHODS_FLAGS_NORMALIZATION = ~0; String name; String descriptor; List<String> thrownTypes; Object annotationDefaultValue; List<List<AnnotationDescription>> classParameterAnnotations; List<List<AnnotationDescription>> runtimeParameterAnnotations; + public MethodDescription() { + flagsNormalization = METHODS_FLAGS_NORMALIZATION; + } + @Override public int hashCode() { int hash = super.hashCode(); hash = 59 * hash + Objects.hashCode(this.name); hash = 59 * hash + Objects.hashCode(this.descriptor);
*** 3760,3769 **** --- 3857,3884 ---- excludeList, descDest, args); break; } + case "build-description-incremental-file": { + if (args.length != 6 && args.length != 7) { + help(); + return ; + } + + if (args.length == 7) { + if ("--normalize-method-flags".equals(args[6])) { + MethodDescription.METHODS_FLAGS_NORMALIZATION = ~(0x100 | 0x20); + } else { + help(); + return ; + } + } + + new CreateSymbols().createIncrementalBaseLineFromDataFile(args[1], args[2], args[3], args[4], "<none>".equals(args[5]) ? null : args[5], args); + break; + } case "build-description-incremental": { if (args.length != 3) { help(); return ; }
< prev index next >