author | mcimadamore |
Mon, 16 May 2016 12:03:41 +0100 | |
changeset 38507 | d48ba9db4b7d |
parent 31506 | 4e07f827a794 |
permissions | -rw-r--r-- |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1 |
/* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2 |
* Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
4 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
10 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
15 |
* accompanied this code). |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
16 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
20 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
23 |
* questions. |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
24 |
*/ |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
25 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
26 |
package build.tools.symbolgenerator; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
27 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
28 |
import java.io.BufferedReader; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
29 |
import java.io.ByteArrayInputStream; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
30 |
import java.io.ByteArrayOutputStream; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
31 |
import java.io.File; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
32 |
import java.io.IOException; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
33 |
import java.io.InputStream; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
34 |
import java.io.OutputStream; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
35 |
import java.io.Writer; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
36 |
import java.nio.file.DirectoryStream; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
37 |
import java.nio.file.Files; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
38 |
import java.nio.file.FileVisitResult; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
39 |
import java.nio.file.FileVisitor; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
40 |
import java.nio.file.Path; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
41 |
import java.nio.file.Paths; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
42 |
import java.nio.file.attribute.BasicFileAttributes; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
43 |
import java.util.stream.Stream; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
44 |
import java.util.ArrayList; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
45 |
import java.util.Arrays; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
46 |
import java.util.Collection; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
47 |
import java.util.Collections; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
48 |
import java.util.HashMap; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
49 |
import java.util.HashSet; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
50 |
import java.util.Iterator; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
51 |
import java.util.LinkedHashMap; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
52 |
import java.util.List; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
53 |
import java.util.Map; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
54 |
import java.util.Map.Entry; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
55 |
import java.util.Objects; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
56 |
import java.util.Set; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
57 |
import java.util.function.Function; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
58 |
import java.util.function.Predicate; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
59 |
import java.util.regex.Matcher; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
60 |
import java.util.regex.Pattern; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
61 |
import java.util.stream.Collectors; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
62 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
63 |
import com.sun.tools.classfile.AccessFlags; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
64 |
import com.sun.tools.classfile.Annotation; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
65 |
import com.sun.tools.classfile.Annotation.Annotation_element_value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
66 |
import com.sun.tools.classfile.Annotation.Array_element_value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
67 |
import com.sun.tools.classfile.Annotation.Class_element_value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
68 |
import com.sun.tools.classfile.Annotation.Enum_element_value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
69 |
import com.sun.tools.classfile.Annotation.Primitive_element_value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
70 |
import com.sun.tools.classfile.Annotation.element_value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
71 |
import com.sun.tools.classfile.Annotation.element_value_pair; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
72 |
import com.sun.tools.classfile.AnnotationDefault_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
73 |
import com.sun.tools.classfile.Attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
74 |
import com.sun.tools.classfile.Attributes; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
75 |
import com.sun.tools.classfile.ClassFile; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
76 |
import com.sun.tools.classfile.ClassWriter; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
77 |
import com.sun.tools.classfile.ConstantPool; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
78 |
import com.sun.tools.classfile.ConstantPool.CONSTANT_Class_info; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
79 |
import com.sun.tools.classfile.ConstantPool.CONSTANT_Double_info; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
80 |
import com.sun.tools.classfile.ConstantPool.CONSTANT_Float_info; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
81 |
import com.sun.tools.classfile.ConstantPool.CONSTANT_Integer_info; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
82 |
import com.sun.tools.classfile.ConstantPool.CONSTANT_Long_info; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
83 |
import com.sun.tools.classfile.ConstantPool.CONSTANT_String_info; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
84 |
import com.sun.tools.classfile.ConstantPool.CONSTANT_Utf8_info; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
85 |
import com.sun.tools.classfile.ConstantPool.CPInfo; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
86 |
import com.sun.tools.classfile.ConstantPool.InvalidIndex; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
87 |
import com.sun.tools.classfile.ConstantPoolException; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
88 |
import com.sun.tools.classfile.ConstantValue_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
89 |
import com.sun.tools.classfile.Deprecated_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
90 |
import com.sun.tools.classfile.Descriptor; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
91 |
import com.sun.tools.classfile.Exceptions_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
92 |
import com.sun.tools.classfile.Field; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
93 |
import com.sun.tools.classfile.InnerClasses_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
94 |
import com.sun.tools.classfile.InnerClasses_attribute.Info; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
95 |
import com.sun.tools.classfile.Method; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
96 |
import com.sun.tools.classfile.RuntimeAnnotations_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
97 |
import com.sun.tools.classfile.RuntimeInvisibleAnnotations_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
98 |
import com.sun.tools.classfile.RuntimeInvisibleParameterAnnotations_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
99 |
import com.sun.tools.classfile.RuntimeParameterAnnotations_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
100 |
import com.sun.tools.classfile.RuntimeVisibleAnnotations_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
101 |
import com.sun.tools.classfile.RuntimeVisibleParameterAnnotations_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
102 |
import com.sun.tools.classfile.Signature_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
103 |
import com.sun.tools.javac.jvm.Target; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
104 |
import com.sun.tools.javac.util.Assert; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
105 |
import com.sun.tools.javac.util.Pair; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
106 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
107 |
/** |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
108 |
* A tool for processing the .sym.txt files. It allows to: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
109 |
* * convert the .sym.txt into class/sig files for ct.sym |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
110 |
* * in cooperation with the adjacent history Probe, construct .sym.txt files for previous platforms |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
111 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
112 |
* To convert the .sym.txt files to class/sig files from ct.sym, run: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
113 |
* java build.tool.symbolgenerator.CreateSymbols build-ctsym [JOINED_VERSIONS|SEPARATE] <platform-description-file> <target-directory> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
114 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
115 |
* The <platform-description-file> is a file of this format: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
116 |
* generate platforms <platform-ids-to-generate separate with ':'> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
117 |
* platform version <platform-id1> files <.sym.txt files containing history data for given platform, separate with ':'> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
118 |
* platform version <platform-id2> base <base-platform-id> files <.sym.txt files containing history data for given platform, separate with ':'> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
119 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
120 |
* The content of platform "<base-platform-id>" is also automatically added to the content of |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
121 |
* platform "<platform-id2>", unless explicitly excluded in "<platform-id2>"'s .sym.txt files. |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
122 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
123 |
* To create the .sym.txt files, first run the history Probe for all the previous platforms: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
124 |
* <jdk-N>/bin/java build.tools.symbolgenerator.Probe <classes-for-N> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
125 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
126 |
* Where <classes-for-N> is a name of a file into which the classes from the bootclasspath of <jdk-N> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
127 |
* will be written. |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
128 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
129 |
* Then create the <platform-description-file> file and the .sym.txt files like this: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
130 |
* java build.tools.symbolgenerator.CreateSymbols build-description <target-directory> <path-to-a-JDK-root> <include-list-file> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
131 |
* <platform-id1> <target-file-for-platform1> "<none>" |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
132 |
* <platform-id2> <target-file-for-platform2> <diff-against-platform2> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
133 |
* <platform-id3> <target-file-for-platform3> <diff-against-platform3> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
134 |
* ... |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
135 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
136 |
* The <include-list-file> is a file that specifies classes that should be included/excluded. |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
137 |
* Lines that start with '+' represent class or package that should be included, '-' class or package |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
138 |
* that should be excluded. '/' should be used as package name delimiter, packages should end with '/'. |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
139 |
* Several include list files may be specified, separated by File.pathSeparator. |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
140 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
141 |
* When <diff-against-platformN> is specified, the .sym.txt files for platform N will only contain |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
142 |
* differences between platform N and the specified platform. The first platform (denoted F further) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
143 |
* that is specified should use literal value "<none>", to have all the APIs of the platform written to |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
144 |
* the .sym.txt files. If there is an existing platform with full .sym.txt files in the repository, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
145 |
* that platform should be used as the first platform to avoid unnecessary changes to the .sym.txt |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
146 |
* files. The <diff-against-platformN> for platform N should be determined as follows: if N < F, then |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
147 |
* <diff-against-platformN> should be N + 1. If F < N, then <diff-against-platformN> should be N - 1. |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
148 |
* If N is a custom/specialized sub-version of another platform N', then <diff-against-platformN> should be N'. |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
149 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
150 |
* To generate the .sym.txt files for OpenJDK 7 and 8: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
151 |
* <jdk-7>/bin/java build.tools.symbolgenerator.Probe OpenJDK7.classes |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
152 |
* <jdk-8>/bin/java build.tools.symbolgenerator.Probe OpenJDK8.classes |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
153 |
* java build.tools.symbolgenerator.CreateSymbols build-description langtools/make/data/symbols $TOPDIR langtools/make/data/symbols/include.list |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
154 |
* 8 OpenJDK8.classes '<none>' |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
155 |
* 7 OpenJDK7.classes 8 |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
156 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
157 |
* Note: the versions are expected to be a single character. |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
158 |
*/ |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
159 |
public class CreateSymbols { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
160 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
161 |
//<editor-fold defaultstate="collapsed" desc="ct.sym construction"> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
162 |
/**Create sig files for ct.sym reading the classes description from the directory that contains |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
163 |
* {@code ctDescriptionFile}, using the file as a recipe to create the sigfiles. |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
164 |
*/ |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
165 |
@SuppressWarnings("unchecked") |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
166 |
public void createSymbols(String ctDescriptionFile, String ctSymLocation, CtSymKind ctSymKind) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
167 |
ClassList classes = load(Paths.get(ctDescriptionFile)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
168 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
169 |
splitHeaders(classes); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
170 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
171 |
for (ClassDescription classDescription : classes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
172 |
for (ClassHeaderDescription header : classDescription.header) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
173 |
switch (ctSymKind) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
174 |
case JOINED_VERSIONS: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
175 |
Set<String> jointVersions = new HashSet<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
176 |
jointVersions.add(header.versions); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
177 |
limitJointVersion(jointVersions, classDescription.fields); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
178 |
limitJointVersion(jointVersions, classDescription.methods); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
179 |
writeClassesForVersions(ctSymLocation, classDescription, header, jointVersions); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
180 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
181 |
case SEPARATE: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
182 |
Set<String> versions = new HashSet<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
183 |
for (char v : header.versions.toCharArray()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
184 |
versions.add("" + v); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
185 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
186 |
writeClassesForVersions(ctSymLocation, classDescription, header, versions); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
187 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
188 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
189 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
190 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
191 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
192 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
193 |
public static String EXTENSION = ".sig"; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
194 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
195 |
ClassList load(Path ctDescription) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
196 |
List<PlatformInput> platforms = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
197 |
Set<String> generatePlatforms = null; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
198 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
199 |
try (LineBasedReader reader = new LineBasedReader(ctDescription)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
200 |
while (reader.hasNext()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
201 |
switch (reader.lineKey) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
202 |
case "generate": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
203 |
String[] platformsAttr = reader.attributes.get("platforms").split(":"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
204 |
generatePlatforms = new HashSet<>(Arrays.asList(platformsAttr)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
205 |
reader.moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
206 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
207 |
case "platform": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
208 |
platforms.add(PlatformInput.load(reader)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
209 |
reader.moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
210 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
211 |
default: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
212 |
throw new IllegalStateException("Unknown key: " + reader.lineKey); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
213 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
214 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
215 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
216 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
217 |
Map<String, ClassDescription> classes = new LinkedHashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
218 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
219 |
for (PlatformInput platform: platforms) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
220 |
for (ClassDescription cd : classes.values()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
221 |
addNewVersion(cd.header, platform.basePlatform, platform.version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
222 |
addNewVersion(cd.fields, platform.basePlatform, platform.version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
223 |
addNewVersion(cd.methods, platform.basePlatform, platform.version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
224 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
225 |
for (String input : platform.files) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
226 |
Path inputFile = ctDescription.getParent().resolve(input); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
227 |
try (LineBasedReader reader = new LineBasedReader(inputFile)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
228 |
while (reader.hasNext()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
229 |
String nameAttr = reader.attributes.get("name"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
230 |
ClassDescription cd = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
231 |
classes.computeIfAbsent(nameAttr, n -> new ClassDescription()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
232 |
if ("-class".equals(reader.lineKey)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
233 |
removeVersion(cd.header, h -> true, platform.version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
234 |
reader.moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
235 |
continue; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
236 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
237 |
cd.read(reader, platform.basePlatform, platform.version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
238 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
239 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
240 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
241 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
242 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
243 |
ClassList result = new ClassList(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
244 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
245 |
for (ClassDescription desc : classes.values()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
246 |
for (Iterator<ClassHeaderDescription> chdIt = desc.header.iterator(); chdIt.hasNext();) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
247 |
ClassHeaderDescription chd = chdIt.next(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
248 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
249 |
chd.versions = reduce(chd.versions, generatePlatforms); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
250 |
if (chd.versions.isEmpty()) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
251 |
chdIt.remove(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
252 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
253 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
254 |
if (desc.header.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
255 |
continue; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
256 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
257 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
258 |
for (Iterator<MethodDescription> methodIt = desc.methods.iterator(); methodIt.hasNext();) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
259 |
MethodDescription method = methodIt.next(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
260 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
261 |
method.versions = reduce(method.versions, generatePlatforms); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
262 |
if (method.versions.isEmpty()) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
263 |
methodIt.remove(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
264 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
265 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
266 |
for (Iterator<FieldDescription> fieldIt = desc.fields.iterator(); fieldIt.hasNext();) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
267 |
FieldDescription field = fieldIt.next(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
268 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
269 |
field.versions = reduce(field.versions, generatePlatforms); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
270 |
if (field.versions.isEmpty()) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
271 |
fieldIt.remove(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
272 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
273 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
274 |
result.add(desc); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
275 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
276 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
277 |
return result; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
278 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
279 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
280 |
static final class LineBasedReader implements AutoCloseable { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
281 |
private final BufferedReader input; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
282 |
public String lineKey; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
283 |
public Map<String, String> attributes = new HashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
284 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
285 |
public LineBasedReader(Path input) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
286 |
this.input = Files.newBufferedReader(input); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
287 |
moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
288 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
289 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
290 |
public void moveNext() throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
291 |
String line = input.readLine(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
292 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
293 |
if (line == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
294 |
lineKey = null; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
295 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
296 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
297 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
298 |
if (line.trim().isEmpty() || line.startsWith("#")) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
299 |
moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
300 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
301 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
302 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
303 |
String[] parts = line.split(" "); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
304 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
305 |
lineKey = parts[0]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
306 |
attributes.clear(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
307 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
308 |
for (int i = 1; i < parts.length; i += 2) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
309 |
attributes.put(parts[i], unquote(parts[i + 1])); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
310 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
311 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
312 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
313 |
public boolean hasNext() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
314 |
return lineKey != null; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
315 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
316 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
317 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
318 |
public void close() throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
319 |
input.close(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
320 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
321 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
322 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
323 |
private static String reduce(String original, String other) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
324 |
Set<String> otherSet = new HashSet<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
325 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
326 |
for (char v : other.toCharArray()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
327 |
otherSet.add("" + v); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
328 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
329 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
330 |
return reduce(original, otherSet); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
331 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
332 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
333 |
private static String reduce(String original, Set<String> generate) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
334 |
StringBuilder sb = new StringBuilder(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
335 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
336 |
for (char v : original.toCharArray()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
337 |
if (generate.contains("" + v)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
338 |
sb.append(v); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
339 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
340 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
341 |
return sb.toString(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
342 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
343 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
344 |
private static class PlatformInput { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
345 |
public final String version; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
346 |
public final String basePlatform; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
347 |
public final List<String> files; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
348 |
public PlatformInput(String version, String basePlatform, List<String> files) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
349 |
this.version = version; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
350 |
this.basePlatform = basePlatform; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
351 |
this.files = files; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
352 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
353 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
354 |
public static PlatformInput load(LineBasedReader in) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
355 |
return new PlatformInput(in.attributes.get("version"), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
356 |
in.attributes.get("base"), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
357 |
Arrays.asList(in.attributes.get("files").split(":"))); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
358 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
359 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
360 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
361 |
static void addNewVersion(Collection<? extends FeatureDescription> features, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
362 |
String baselineVersion, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
363 |
String version) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
364 |
features.stream() |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
365 |
.filter(f -> f.versions.contains(baselineVersion)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
366 |
.forEach(f -> f.versions += version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
367 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
368 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
369 |
static <T extends FeatureDescription> void removeVersion(Collection<T> features, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
370 |
Predicate<T> shouldRemove, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
371 |
String version) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
372 |
for (T existing : features) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
373 |
if (shouldRemove.test(existing) && existing.versions.endsWith(version)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
374 |
existing.versions = existing.versions.replace(version, ""); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
375 |
return; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
376 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
377 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
378 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
379 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
380 |
/**Changes to class header of an outer class (like adding a new type parameter) may affect |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
381 |
* its innerclasses. So if the outer class's header is different for versions A and B, need to |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
382 |
* split its innerclasses headers to also be different for versions A and B. |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
383 |
*/ |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
384 |
static void splitHeaders(ClassList classes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
385 |
Set<String> ctVersions = new HashSet<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
386 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
387 |
for (ClassDescription cd : classes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
388 |
for (ClassHeaderDescription header : cd.header) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
389 |
for (char c : header.versions.toCharArray()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
390 |
ctVersions.add("" + c); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
391 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
392 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
393 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
394 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
395 |
classes.sort(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
396 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
397 |
for (ClassDescription cd : classes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
398 |
Map<String, String> outerSignatures2Version = new HashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
399 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
400 |
for (String version : ctVersions) { //XXX |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
401 |
ClassDescription outer = cd; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
402 |
String outerSignatures = ""; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
403 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
404 |
while ((outer = classes.enclosingClass(outer)) != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
405 |
for (ClassHeaderDescription outerHeader : outer.header) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
406 |
if (outerHeader.versions.contains(version)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
407 |
outerSignatures += outerHeader.signature; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
408 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
409 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
410 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
411 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
412 |
outerSignatures2Version.compute(outerSignatures, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
413 |
(key, value) -> value != null ? value + version : version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
414 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
415 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
416 |
List<ClassHeaderDescription> newHeaders = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
417 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
418 |
HEADER_LOOP: for (ClassHeaderDescription header : cd.header) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
419 |
for (String versions : outerSignatures2Version.values()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
420 |
if (containsAll(versions, header.versions)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
421 |
newHeaders.add(header); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
422 |
continue HEADER_LOOP; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
423 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
424 |
if (disjoint(versions, header.versions)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
425 |
continue; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
426 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
427 |
ClassHeaderDescription newHeader = new ClassHeaderDescription(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
428 |
newHeader.classAnnotations = header.classAnnotations; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
429 |
newHeader.deprecated = header.deprecated; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
430 |
newHeader.extendsAttr = header.extendsAttr; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
431 |
newHeader.flags = header.flags; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
432 |
newHeader.implementsAttr = header.implementsAttr; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
433 |
newHeader.innerClasses = header.innerClasses; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
434 |
newHeader.runtimeAnnotations = header.runtimeAnnotations; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
435 |
newHeader.signature = header.signature; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
436 |
newHeader.versions = reduce(versions, header.versions); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
437 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
438 |
newHeaders.add(newHeader); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
439 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
440 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
441 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
442 |
cd.header = newHeaders; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
443 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
444 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
445 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
446 |
void limitJointVersion(Set<String> jointVersions, List<? extends FeatureDescription> features) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
447 |
for (FeatureDescription feature : features) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
448 |
for (String version : jointVersions) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
449 |
if (!containsAll(feature.versions, version) && |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
450 |
!disjoint(feature.versions, version)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
451 |
StringBuilder featurePart = new StringBuilder(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
452 |
StringBuilder otherPart = new StringBuilder(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
453 |
for (char v : version.toCharArray()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
454 |
if (feature.versions.indexOf(v) != (-1)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
455 |
featurePart.append(v); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
456 |
} else { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
457 |
otherPart.append(v); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
458 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
459 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
460 |
jointVersions.remove(version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
461 |
if (featurePart.length() == 0 || otherPart.length() == 0) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
462 |
throw new AssertionError(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
463 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
464 |
jointVersions.add(featurePart.toString()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
465 |
jointVersions.add(otherPart.toString()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
466 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
467 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
468 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
469 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
470 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
471 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
472 |
private static boolean containsAll(String versions, String subVersions) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
473 |
for (char c : subVersions.toCharArray()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
474 |
if (versions.indexOf(c) == (-1)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
475 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
476 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
477 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
478 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
479 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
480 |
private static boolean disjoint(String version1, String version2) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
481 |
for (char c : version2.toCharArray()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
482 |
if (version1.indexOf(c) != (-1)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
483 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
484 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
485 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
486 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
487 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
488 |
void writeClassesForVersions(String ctSymLocation, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
489 |
ClassDescription classDescription, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
490 |
ClassHeaderDescription header, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
491 |
Iterable<String> versions) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
492 |
for (String ver : versions) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
493 |
writeClass(ctSymLocation, classDescription, header, ver); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
494 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
495 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
496 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
497 |
public enum CtSymKind { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
498 |
JOINED_VERSIONS, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
499 |
SEPARATE; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
500 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
501 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
502 |
//<editor-fold defaultstate="collapsed" desc="Class Writing"> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
503 |
void writeClass(String ctSymLocation, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
504 |
ClassDescription classDescription, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
505 |
ClassHeaderDescription header, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
506 |
String version) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
507 |
List<CPInfo> constantPool = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
508 |
constantPool.add(null); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
509 |
List<Method> methods = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
510 |
for (MethodDescription methDesc : classDescription.methods) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
511 |
if (disjoint(methDesc.versions, version)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
512 |
continue; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
513 |
Descriptor descriptor = new Descriptor(addString(constantPool, methDesc.descriptor)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
514 |
//TODO: LinkedHashMap to avoid param annotations vs. Signature problem in javac's ClassReader: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
515 |
Map<String, Attribute> attributesMap = new LinkedHashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
516 |
addAttributes(methDesc, constantPool, attributesMap); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
517 |
Attributes attributes = new Attributes(attributesMap); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
518 |
AccessFlags flags = new AccessFlags(methDesc.flags); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
519 |
int nameString = addString(constantPool, methDesc.name); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
520 |
methods.add(new Method(flags, nameString, descriptor, attributes)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
521 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
522 |
List<Field> fields = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
523 |
for (FieldDescription fieldDesc : classDescription.fields) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
524 |
if (disjoint(fieldDesc.versions, version)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
525 |
continue; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
526 |
Descriptor descriptor = new Descriptor(addString(constantPool, fieldDesc.descriptor)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
527 |
Map<String, Attribute> attributesMap = new HashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
528 |
addAttributes(fieldDesc, constantPool, attributesMap); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
529 |
Attributes attributes = new Attributes(attributesMap); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
530 |
AccessFlags flags = new AccessFlags(fieldDesc.flags); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
531 |
int nameString = addString(constantPool, fieldDesc.name); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
532 |
fields.add(new Field(flags, nameString, descriptor, attributes)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
533 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
534 |
int currentClass = addClass(constantPool, classDescription.name); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
535 |
int superclass = header.extendsAttr != null ? addClass(constantPool, header.extendsAttr) : 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
536 |
int[] interfaces = new int[header.implementsAttr.size()]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
537 |
int i = 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
538 |
for (String intf : header.implementsAttr) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
539 |
interfaces[i++] = addClass(constantPool, intf); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
540 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
541 |
AccessFlags flags = new AccessFlags(header.flags); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
542 |
Map<String, Attribute> attributesMap = new HashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
543 |
addAttributes(header, constantPool, attributesMap); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
544 |
Attributes attributes = new Attributes(attributesMap); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
545 |
ConstantPool cp = new ConstantPool(constantPool.toArray(new CPInfo[constantPool.size()])); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
546 |
ClassFile classFile = new ClassFile(0xCAFEBABE, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
547 |
Target.DEFAULT.minorVersion, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
548 |
Target.DEFAULT.majorVersion, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
549 |
cp, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
550 |
flags, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
551 |
currentClass, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
552 |
superclass, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
553 |
interfaces, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
554 |
fields.toArray(new Field[0]), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
555 |
methods.toArray(new Method[0]), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
556 |
attributes); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
557 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
558 |
Path outputClassFile = Paths.get(ctSymLocation, version, classDescription.name + EXTENSION); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
559 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
560 |
Files.createDirectories(outputClassFile.getParent()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
561 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
562 |
try (OutputStream out = Files.newOutputStream(outputClassFile)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
563 |
ClassWriter w = new ClassWriter(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
564 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
565 |
w.write(classFile, out); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
566 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
567 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
568 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
569 |
private void addAttributes(ClassHeaderDescription header, List<CPInfo> constantPool, Map<String, Attribute> attributes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
570 |
addGenericAttributes(header, constantPool, attributes); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
571 |
if (header.innerClasses != null && !header.innerClasses.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
572 |
Info[] innerClasses = new Info[header.innerClasses.size()]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
573 |
int i = 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
574 |
for (InnerClassInfo info : header.innerClasses) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
575 |
innerClasses[i++] = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
576 |
new Info(info.innerClass == null ? 0 : addClass(constantPool, info.innerClass), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
577 |
info.outerClass == null ? 0 : addClass(constantPool, info.outerClass), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
578 |
info.innerClassName == null ? 0 : addString(constantPool, info.innerClassName), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
579 |
new AccessFlags(info.innerClassFlags)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
580 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
581 |
int attributeString = addString(constantPool, Attribute.InnerClasses); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
582 |
attributes.put(Attribute.InnerClasses, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
583 |
new InnerClasses_attribute(attributeString, innerClasses)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
584 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
585 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
586 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
587 |
private void addAttributes(MethodDescription desc, List<CPInfo> constantPool, Map<String, Attribute> attributes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
588 |
addGenericAttributes(desc, constantPool, attributes); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
589 |
if (desc.thrownTypes != null && !desc.thrownTypes.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
590 |
int[] exceptions = new int[desc.thrownTypes.size()]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
591 |
int i = 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
592 |
for (String exc : desc.thrownTypes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
593 |
exceptions[i++] = addClass(constantPool, exc); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
594 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
595 |
int attributeString = addString(constantPool, Attribute.Exceptions); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
596 |
attributes.put(Attribute.Exceptions, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
597 |
new Exceptions_attribute(attributeString, exceptions)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
598 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
599 |
if (desc.annotationDefaultValue != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
600 |
int attributeString = addString(constantPool, Attribute.AnnotationDefault); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
601 |
element_value attributeValue = createAttributeValue(constantPool, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
602 |
desc.annotationDefaultValue); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
603 |
attributes.put(Attribute.AnnotationDefault, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
604 |
new AnnotationDefault_attribute(attributeString, attributeValue)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
605 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
606 |
if (desc.classParameterAnnotations != null && !desc.classParameterAnnotations.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
607 |
int attributeString = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
608 |
addString(constantPool, Attribute.RuntimeInvisibleParameterAnnotations); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
609 |
Annotation[][] annotations = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
610 |
createParameterAnnotations(constantPool, desc.classParameterAnnotations); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
611 |
attributes.put(Attribute.RuntimeInvisibleParameterAnnotations, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
612 |
new RuntimeInvisibleParameterAnnotations_attribute(attributeString, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
613 |
annotations)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
614 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
615 |
if (desc.runtimeParameterAnnotations != null && !desc.runtimeParameterAnnotations.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
616 |
int attributeString = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
617 |
addString(constantPool, Attribute.RuntimeVisibleParameterAnnotations); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
618 |
Annotation[][] annotations = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
619 |
createParameterAnnotations(constantPool, desc.runtimeParameterAnnotations); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
620 |
attributes.put(Attribute.RuntimeVisibleParameterAnnotations, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
621 |
new RuntimeVisibleParameterAnnotations_attribute(attributeString, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
622 |
annotations)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
623 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
624 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
625 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
626 |
private void addAttributes(FieldDescription desc, List<CPInfo> constantPool, Map<String, Attribute> attributes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
627 |
addGenericAttributes(desc, constantPool, attributes); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
628 |
if (desc.constantValue != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
629 |
Pair<Integer, Character> constantPoolEntry = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
630 |
addConstant(constantPool, desc.constantValue, false); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
631 |
Assert.checkNonNull(constantPoolEntry); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
632 |
int constantValueString = addString(constantPool, Attribute.ConstantValue); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
633 |
attributes.put(Attribute.ConstantValue, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
634 |
new ConstantValue_attribute(constantValueString, constantPoolEntry.fst)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
635 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
636 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
637 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
638 |
private void addGenericAttributes(FeatureDescription desc, List<CPInfo> constantPool, Map<String, Attribute> attributes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
639 |
if (desc.deprecated) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
640 |
int attributeString = addString(constantPool, Attribute.Deprecated); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
641 |
attributes.put(Attribute.Deprecated, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
642 |
new Deprecated_attribute(attributeString)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
643 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
644 |
if (desc.signature != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
645 |
int attributeString = addString(constantPool, Attribute.Signature); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
646 |
int signatureString = addString(constantPool, desc.signature); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
647 |
attributes.put(Attribute.Signature, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
648 |
new Signature_attribute(attributeString, signatureString)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
649 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
650 |
if (desc.classAnnotations != null && !desc.classAnnotations.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
651 |
int attributeString = addString(constantPool, Attribute.RuntimeInvisibleAnnotations); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
652 |
Annotation[] annotations = createAnnotations(constantPool, desc.classAnnotations); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
653 |
attributes.put(Attribute.RuntimeInvisibleAnnotations, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
654 |
new RuntimeInvisibleAnnotations_attribute(attributeString, annotations)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
655 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
656 |
if (desc.runtimeAnnotations != null && !desc.runtimeAnnotations.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
657 |
int attributeString = addString(constantPool, Attribute.RuntimeVisibleAnnotations); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
658 |
Annotation[] annotations = createAnnotations(constantPool, desc.runtimeAnnotations); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
659 |
attributes.put(Attribute.RuntimeVisibleAnnotations, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
660 |
new RuntimeVisibleAnnotations_attribute(attributeString, annotations)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
661 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
662 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
663 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
664 |
private Annotation[] createAnnotations(List<CPInfo> constantPool, List<AnnotationDescription> desc) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
665 |
Annotation[] result = new Annotation[desc.size()]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
666 |
int i = 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
667 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
668 |
for (AnnotationDescription ad : desc) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
669 |
result[i++] = createAnnotation(constantPool, ad); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
670 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
671 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
672 |
return result; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
673 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
674 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
675 |
private Annotation[][] createParameterAnnotations(List<CPInfo> constantPool, List<List<AnnotationDescription>> desc) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
676 |
Annotation[][] result = new Annotation[desc.size()][]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
677 |
int i = 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
678 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
679 |
for (List<AnnotationDescription> paramAnnos : desc) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
680 |
result[i++] = createAnnotations(constantPool, paramAnnos); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
681 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
682 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
683 |
return result; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
684 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
685 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
686 |
private Annotation createAnnotation(List<CPInfo> constantPool, AnnotationDescription desc) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
687 |
return new Annotation(null, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
688 |
addString(constantPool, desc.annotationType), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
689 |
createElementPairs(constantPool, desc.values)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
690 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
691 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
692 |
private element_value_pair[] createElementPairs(List<CPInfo> constantPool, Map<String, Object> annotationAttributes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
693 |
element_value_pair[] pairs = new element_value_pair[annotationAttributes.size()]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
694 |
int i = 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
695 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
696 |
for (Entry<String, Object> e : annotationAttributes.entrySet()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
697 |
int elementNameString = addString(constantPool, e.getKey()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
698 |
element_value value = createAttributeValue(constantPool, e.getValue()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
699 |
pairs[i++] = new element_value_pair(elementNameString, value); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
700 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
701 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
702 |
return pairs; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
703 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
704 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
705 |
private element_value createAttributeValue(List<CPInfo> constantPool, Object value) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
706 |
Pair<Integer, Character> constantPoolEntry = addConstant(constantPool, value, true); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
707 |
if (constantPoolEntry != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
708 |
return new Primitive_element_value(constantPoolEntry.fst, constantPoolEntry.snd); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
709 |
} else if (value instanceof EnumConstant) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
710 |
EnumConstant ec = (EnumConstant) value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
711 |
return new Enum_element_value(addString(constantPool, ec.type), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
712 |
addString(constantPool, ec.constant), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
713 |
'e'); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
714 |
} else if (value instanceof ClassConstant) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
715 |
ClassConstant cc = (ClassConstant) value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
716 |
return new Class_element_value(addString(constantPool, cc.type), 'c'); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
717 |
} else if (value instanceof AnnotationDescription) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
718 |
Annotation annotation = createAnnotation(constantPool, ((AnnotationDescription) value)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
719 |
return new Annotation_element_value(annotation, '@'); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
720 |
} else if (value instanceof Collection) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
721 |
@SuppressWarnings("unchecked") |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
722 |
Collection<Object> array = (Collection<Object>) value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
723 |
element_value[] values = new element_value[array.size()]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
724 |
int i = 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
725 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
726 |
for (Object elem : array) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
727 |
values[i++] = createAttributeValue(constantPool, elem); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
728 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
729 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
730 |
return new Array_element_value(values, '['); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
731 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
732 |
throw new IllegalStateException(value.getClass().getName()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
733 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
734 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
735 |
private static Pair<Integer, Character> addConstant(List<CPInfo> constantPool, Object value, boolean annotation) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
736 |
if (value instanceof Boolean) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
737 |
return Pair.of(addToCP(constantPool, new CONSTANT_Integer_info(((Boolean) value) ? 1 : 0)), 'Z'); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
738 |
} else if (value instanceof Byte) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
739 |
return Pair.of(addToCP(constantPool, new CONSTANT_Integer_info((byte) value)), 'B'); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
740 |
} else if (value instanceof Character) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
741 |
return Pair.of(addToCP(constantPool, new CONSTANT_Integer_info((char) value)), 'C'); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
742 |
} else if (value instanceof Short) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
743 |
return Pair.of(addToCP(constantPool, new CONSTANT_Integer_info((short) value)), 'S'); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
744 |
} else if (value instanceof Integer) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
745 |
return Pair.of(addToCP(constantPool, new CONSTANT_Integer_info((int) value)), 'I'); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
746 |
} else if (value instanceof Long) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
747 |
return Pair.of(addToCP(constantPool, new CONSTANT_Long_info((long) value)), 'J'); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
748 |
} else if (value instanceof Float) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
749 |
return Pair.of(addToCP(constantPool, new CONSTANT_Float_info((float) value)), 'F'); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
750 |
} else if (value instanceof Double) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
751 |
return Pair.of(addToCP(constantPool, new CONSTANT_Double_info((double) value)), 'D'); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
752 |
} else if (value instanceof String) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
753 |
int stringIndex = addString(constantPool, (String) value); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
754 |
if (annotation) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
755 |
return Pair.of(stringIndex, 's'); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
756 |
} else { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
757 |
return Pair.of(addToCP(constantPool, new CONSTANT_String_info(null, stringIndex)), 's'); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
758 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
759 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
760 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
761 |
return null; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
762 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
763 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
764 |
private static int addString(List<CPInfo> constantPool, String string) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
765 |
Assert.checkNonNull(string); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
766 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
767 |
int i = 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
768 |
for (CPInfo info : constantPool) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
769 |
if (info instanceof CONSTANT_Utf8_info) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
770 |
if (((CONSTANT_Utf8_info) info).value.equals(string)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
771 |
return i; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
772 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
773 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
774 |
i++; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
775 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
776 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
777 |
return addToCP(constantPool, new CONSTANT_Utf8_info(string)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
778 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
779 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
780 |
private static int addToCP(List<CPInfo> constantPool, CPInfo entry) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
781 |
int result = constantPool.size(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
782 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
783 |
constantPool.add(entry); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
784 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
785 |
if (entry.size() > 1) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
786 |
constantPool.add(null); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
787 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
788 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
789 |
return result; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
790 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
791 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
792 |
private static int addClass(List<CPInfo> constantPool, String className) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
793 |
int classNameIndex = addString(constantPool, className); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
794 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
795 |
int i = 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
796 |
for (CPInfo info : constantPool) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
797 |
if (info instanceof CONSTANT_Class_info) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
798 |
if (((CONSTANT_Class_info) info).name_index == classNameIndex) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
799 |
return i; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
800 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
801 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
802 |
i++; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
803 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
804 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
805 |
return addToCP(constantPool, new CONSTANT_Class_info(null, classNameIndex)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
806 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
807 |
//</editor-fold> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
808 |
//</editor-fold> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
809 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
810 |
//<editor-fold defaultstate="collapsed" desc="Create Symbol Description"> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
811 |
public void createBaseLine(List<VersionDescription> versions, ExcludeIncludeList excludesIncludes, Path descDest, Path jdkRoot) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
812 |
ClassList classes = new ClassList(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
813 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
814 |
for (VersionDescription desc : versions) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
815 |
ClassList currentVersionClasses = new ClassList(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
816 |
try (BufferedReader descIn = Files.newBufferedReader(Paths.get(desc.classes))) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
817 |
String classFileData; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
818 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
819 |
while ((classFileData = descIn.readLine()) != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
820 |
ByteArrayOutputStream data = new ByteArrayOutputStream(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
821 |
for (int i = 0; i < classFileData.length(); i += 2) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
822 |
data.write(Integer.parseInt(classFileData.substring(i, i + 2), 16)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
823 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
824 |
try (InputStream in = new ByteArrayInputStream(data.toByteArray())) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
825 |
inspectClassFile(in, currentVersionClasses, excludesIncludes, desc.version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
826 |
} catch (IOException | ConstantPoolException ex) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
827 |
throw new IllegalStateException(ex); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
828 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
829 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
830 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
831 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
832 |
Set<String> includedClasses = new HashSet<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
833 |
boolean modified; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
834 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
835 |
do { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
836 |
modified = false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
837 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
838 |
for (ClassDescription clazz : currentVersionClasses) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
839 |
ClassHeaderDescription header = clazz.header.get(0); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
840 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
841 |
if (includeEffectiveAccess(currentVersionClasses, clazz)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
842 |
modified |= include(includedClasses, currentVersionClasses, clazz.name); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
843 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
844 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
845 |
if (includedClasses.contains(clazz.name)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
846 |
modified |= include(includedClasses, currentVersionClasses, header.extendsAttr); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
847 |
for (String i : header.implementsAttr) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
848 |
modified |= include(includedClasses, currentVersionClasses, i); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
849 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
850 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
851 |
modified |= includeOutputType(Collections.singleton(header), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
852 |
h -> "", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
853 |
includedClasses, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
854 |
currentVersionClasses); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
855 |
modified |= includeOutputType(clazz.fields, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
856 |
f -> f.descriptor, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
857 |
includedClasses, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
858 |
currentVersionClasses); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
859 |
modified |= includeOutputType(clazz.methods, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
860 |
m -> m.descriptor, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
861 |
includedClasses, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
862 |
currentVersionClasses); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
863 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
864 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
865 |
} while (modified); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
866 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
867 |
for (ClassDescription clazz : currentVersionClasses) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
868 |
if (!includedClasses.contains(clazz.name)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
869 |
continue; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
870 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
871 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
872 |
ClassHeaderDescription header = clazz.header.get(0); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
873 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
874 |
if (header.innerClasses != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
875 |
Iterator<InnerClassInfo> innerClassIt = header.innerClasses.iterator(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
876 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
877 |
while(innerClassIt.hasNext()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
878 |
InnerClassInfo ici = innerClassIt.next(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
879 |
if (!includedClasses.contains(ici.innerClass)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
880 |
innerClassIt.remove(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
881 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
882 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
883 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
884 |
ClassDescription existing = classes.find(clazz.name, true); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
885 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
886 |
if (existing != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
887 |
addClassHeader(existing, header, desc.version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
888 |
for (MethodDescription currentMethod : clazz.methods) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
889 |
addMethod(existing, currentMethod, desc.version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
890 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
891 |
for (FieldDescription currentField : clazz.fields) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
892 |
addField(existing, currentField, desc.version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
893 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
894 |
} else { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
895 |
classes.add(clazz); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
896 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
897 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
898 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
899 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
900 |
classes.sort(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
901 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
902 |
Map<String, String> package2Modules = buildPackage2Modules(jdkRoot); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
903 |
Map<String, List<ClassDescription>> module2Classes = new HashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
904 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
905 |
for (ClassDescription clazz : classes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
906 |
String pack; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
907 |
int lastSlash = clazz.name.lastIndexOf('/'); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
908 |
if (lastSlash != (-1)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
909 |
pack = clazz.name.substring(0, lastSlash).replace('/', '.'); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
910 |
} else { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
911 |
pack = ""; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
912 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
913 |
String module = package2Modules.get(pack); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
914 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
915 |
if (module == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
916 |
module = "java.base"; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
917 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
918 |
OUTER: while (!pack.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
919 |
for (Entry<String, String> p2M : package2Modules.entrySet()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
920 |
if (p2M.getKey().startsWith(pack)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
921 |
module = p2M.getValue(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
922 |
break OUTER; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
923 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
924 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
925 |
int dot = pack.lastIndexOf('.'); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
926 |
if (dot == (-1)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
927 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
928 |
pack = pack.substring(0, dot); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
929 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
930 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
931 |
module2Classes.computeIfAbsent(module, m -> new ArrayList<>()) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
932 |
.add(clazz); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
933 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
934 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
935 |
Path symbolsFile = descDest.resolve("symbols"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
936 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
937 |
Files.createDirectories(symbolsFile.getParent()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
938 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
939 |
try (Writer symbolsOut = Files.newBufferedWriter(symbolsFile)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
940 |
Map<VersionDescription, List<Path>> outputFiles = new LinkedHashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
941 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
942 |
for (Entry<String, List<ClassDescription>> e : module2Classes.entrySet()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
943 |
for (VersionDescription desc : versions) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
944 |
Path f = descDest.resolve(e.getKey() + "-" + desc.version + ".sym.txt"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
945 |
try (Writer out = Files.newBufferedWriter(f)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
946 |
for (ClassDescription clazz : e.getValue()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
947 |
clazz.write(out, desc.primaryBaseline, desc.version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
948 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
949 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
950 |
outputFiles.computeIfAbsent(desc, d -> new ArrayList<>()) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
951 |
.add(f); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
952 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
953 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
954 |
symbolsOut.append("generate platforms ") |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
955 |
.append(versions.stream() |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
956 |
.map(v -> v.version) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
957 |
.collect(Collectors.joining(":"))) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
958 |
.append("\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
959 |
for (Entry<VersionDescription, List<Path>> versionFileEntry : outputFiles.entrySet()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
960 |
symbolsOut.append("platform version ") |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
961 |
.append(versionFileEntry.getKey().version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
962 |
if (versionFileEntry.getKey().primaryBaseline != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
963 |
symbolsOut.append(" base ") |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
964 |
.append(versionFileEntry.getKey().primaryBaseline); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
965 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
966 |
symbolsOut.append(" files ") |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
967 |
.append(versionFileEntry.getValue() |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
968 |
.stream() |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
969 |
.map(p -> p.getFileName().toString()) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
970 |
.sorted() |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
971 |
.collect(Collectors.joining(":"))) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
972 |
.append("\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
973 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
974 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
975 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
976 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
977 |
//<editor-fold defaultstate="collapsed" desc="Class Reading"> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
978 |
//non-final for tests: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
979 |
public static String PROFILE_ANNOTATION = "Ljdk/Profile+Annotation;"; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
980 |
public static boolean ALLOW_NON_EXISTING_CLASSES = false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
981 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
982 |
private void inspectClassFile(InputStream in, ClassList classes, ExcludeIncludeList excludesIncludes, String version) throws IOException, ConstantPoolException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
983 |
ClassFile cf = ClassFile.read(in); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
984 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
985 |
if (!excludesIncludes.accepts(cf.getName())) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
986 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
987 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
988 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
989 |
ClassHeaderDescription headerDesc = new ClassHeaderDescription(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
990 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
991 |
headerDesc.flags = cf.access_flags.flags; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
992 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
993 |
if (cf.super_class != 0) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
994 |
headerDesc.extendsAttr = cf.getSuperclassName(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
995 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
996 |
List<String> interfaces = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
997 |
for (int i = 0; i < cf.interfaces.length; i++) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
998 |
interfaces.add(cf.getInterfaceName(i)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
999 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1000 |
headerDesc.implementsAttr = interfaces; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1001 |
for (Attribute attr : cf.attributes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1002 |
if (!readAttribute(cf, headerDesc, attr)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1003 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1004 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1005 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1006 |
ClassDescription clazzDesc = null; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1007 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1008 |
for (ClassDescription cd : classes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1009 |
if (cd.name.equals(cf.getName())) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1010 |
clazzDesc = cd; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1011 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1012 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1013 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1014 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1015 |
if (clazzDesc == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1016 |
clazzDesc = new ClassDescription(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1017 |
clazzDesc.name = cf.getName(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1018 |
classes.add(clazzDesc); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1019 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1020 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1021 |
addClassHeader(clazzDesc, headerDesc, version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1022 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1023 |
for (Method m : cf.methods) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1024 |
if (!include(m.access_flags.flags)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1025 |
continue; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1026 |
MethodDescription methDesc = new MethodDescription(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1027 |
methDesc.flags = m.access_flags.flags; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1028 |
methDesc.name = m.getName(cf.constant_pool); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1029 |
methDesc.descriptor = m.descriptor.getValue(cf.constant_pool); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1030 |
for (Attribute attr : m.attributes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1031 |
readAttribute(cf, methDesc, attr); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1032 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1033 |
addMethod(clazzDesc, methDesc, version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1034 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1035 |
for (Field f : cf.fields) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1036 |
if (!include(f.access_flags.flags)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1037 |
continue; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1038 |
FieldDescription fieldDesc = new FieldDescription(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1039 |
fieldDesc.flags = f.access_flags.flags; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1040 |
fieldDesc.name = f.getName(cf.constant_pool); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1041 |
fieldDesc.descriptor = f.descriptor.getValue(cf.constant_pool); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1042 |
for (Attribute attr : f.attributes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1043 |
readAttribute(cf, fieldDesc, attr); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1044 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1045 |
addField(clazzDesc, fieldDesc, version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1046 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1047 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1048 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1049 |
private boolean include(int accessFlags) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1050 |
return (accessFlags & (AccessFlags.ACC_PUBLIC | AccessFlags.ACC_PROTECTED)) != 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1051 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1052 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1053 |
private void addClassHeader(ClassDescription clazzDesc, ClassHeaderDescription headerDesc, String version) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1054 |
//normalize: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1055 |
boolean existed = false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1056 |
for (ClassHeaderDescription existing : clazzDesc.header) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1057 |
if (existing.equals(headerDesc)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1058 |
headerDesc = existing; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1059 |
existed = true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1060 |
} else { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1061 |
//check if the only difference between the 7 and 8 version is the Profile annotation |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1062 |
//if so, copy it to the pre-8 version, so save space |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1063 |
List<AnnotationDescription> annots = headerDesc.classAnnotations; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1064 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1065 |
if (annots != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1066 |
for (AnnotationDescription ad : annots) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1067 |
if (PROFILE_ANNOTATION.equals(ad.annotationType)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1068 |
annots.remove(ad); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1069 |
if (existing.equals(headerDesc)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1070 |
headerDesc = existing; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1071 |
annots = headerDesc.classAnnotations; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1072 |
if (annots == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1073 |
headerDesc.classAnnotations = annots = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1074 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1075 |
annots.add(ad); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1076 |
existed = true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1077 |
} else { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1078 |
annots.add(ad); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1079 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1080 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1081 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1082 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1083 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1084 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1085 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1086 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1087 |
headerDesc.versions += version; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1088 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1089 |
if (!existed) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1090 |
clazzDesc.header.add(headerDesc); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1091 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1092 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1093 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1094 |
private void addMethod(ClassDescription clazzDesc, MethodDescription methDesc, String version) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1095 |
//normalize: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1096 |
boolean methodExisted = false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1097 |
for (MethodDescription existing : clazzDesc.methods) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1098 |
if (existing.equals(methDesc)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1099 |
methodExisted = true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1100 |
methDesc = existing; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1101 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1102 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1103 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1104 |
methDesc.versions += version; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1105 |
if (!methodExisted) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1106 |
clazzDesc.methods.add(methDesc); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1107 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1108 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1109 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1110 |
private void addField(ClassDescription clazzDesc, FieldDescription fieldDesc, String version) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1111 |
boolean fieldExisted = false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1112 |
for (FieldDescription existing : clazzDesc.fields) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1113 |
if (existing.equals(fieldDesc)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1114 |
fieldExisted = true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1115 |
fieldDesc = existing; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1116 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1117 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1118 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1119 |
fieldDesc.versions += version; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1120 |
if (!fieldExisted) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1121 |
clazzDesc.fields.add(fieldDesc); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1122 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1123 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1124 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1125 |
private boolean readAttribute(ClassFile cf, FeatureDescription feature, Attribute attr) throws ConstantPoolException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1126 |
String attrName = attr.getName(cf.constant_pool); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1127 |
switch (attrName) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1128 |
case Attribute.AnnotationDefault: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1129 |
assert feature instanceof MethodDescription; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1130 |
element_value defaultValue = ((AnnotationDefault_attribute) attr).default_value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1131 |
((MethodDescription) feature).annotationDefaultValue = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1132 |
convertElementValue(cf.constant_pool, defaultValue); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1133 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1134 |
case "Deprecated": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1135 |
feature.deprecated = true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1136 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1137 |
case "Exceptions": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1138 |
assert feature instanceof MethodDescription; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1139 |
List<String> thrownTypes = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1140 |
Exceptions_attribute exceptionAttr = (Exceptions_attribute) attr; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1141 |
for (int i = 0; i < exceptionAttr.exception_index_table.length; i++) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1142 |
thrownTypes.add(exceptionAttr.getException(i, cf.constant_pool)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1143 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1144 |
((MethodDescription) feature).thrownTypes = thrownTypes; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1145 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1146 |
case Attribute.InnerClasses: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1147 |
assert feature instanceof ClassHeaderDescription; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1148 |
List<InnerClassInfo> innerClasses = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1149 |
InnerClasses_attribute innerClassesAttr = (InnerClasses_attribute) attr; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1150 |
for (int i = 0; i < innerClassesAttr.number_of_classes; i++) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1151 |
CONSTANT_Class_info outerClassInfo = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1152 |
innerClassesAttr.classes[i].getOuterClassInfo(cf.constant_pool); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1153 |
InnerClassInfo info = new InnerClassInfo(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1154 |
CONSTANT_Class_info innerClassInfo = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1155 |
innerClassesAttr.classes[i].getInnerClassInfo(cf.constant_pool); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1156 |
info.innerClass = innerClassInfo != null ? innerClassInfo.getName() : null; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1157 |
info.outerClass = outerClassInfo != null ? outerClassInfo.getName() : null; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1158 |
info.innerClassName = innerClassesAttr.classes[i].getInnerName(cf.constant_pool); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1159 |
info.innerClassFlags = innerClassesAttr.classes[i].inner_class_access_flags.flags; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1160 |
innerClasses.add(info); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1161 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1162 |
((ClassHeaderDescription) feature).innerClasses = innerClasses; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1163 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1164 |
case "RuntimeInvisibleAnnotations": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1165 |
feature.classAnnotations = annotations2Description(cf.constant_pool, attr); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1166 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1167 |
case "RuntimeVisibleAnnotations": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1168 |
feature.runtimeAnnotations = annotations2Description(cf.constant_pool, attr); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1169 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1170 |
case "Signature": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1171 |
feature.signature = ((Signature_attribute) attr).getSignature(cf.constant_pool); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1172 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1173 |
case "ConstantValue": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1174 |
assert feature instanceof FieldDescription; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1175 |
Object value = convertConstantValue(cf.constant_pool.get(((ConstantValue_attribute) attr).constantvalue_index), ((FieldDescription) feature).descriptor); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1176 |
if (((FieldDescription) feature).descriptor.equals("C")) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1177 |
value = (char) (int) value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1178 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1179 |
((FieldDescription) feature).constantValue = value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1180 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1181 |
case "SourceFile": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1182 |
//ignore, not needed |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1183 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1184 |
case "BootstrapMethods": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1185 |
//ignore, not needed |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1186 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1187 |
case "Code": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1188 |
//ignore, not needed |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1189 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1190 |
case "EnclosingMethod": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1191 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1192 |
case "Synthetic": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1193 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1194 |
case "RuntimeVisibleParameterAnnotations": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1195 |
assert feature instanceof MethodDescription; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1196 |
((MethodDescription) feature).runtimeParameterAnnotations = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1197 |
parameterAnnotations2Description(cf.constant_pool, attr); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1198 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1199 |
case "RuntimeInvisibleParameterAnnotations": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1200 |
assert feature instanceof MethodDescription; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1201 |
((MethodDescription) feature).classParameterAnnotations = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1202 |
parameterAnnotations2Description(cf.constant_pool, attr); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1203 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1204 |
default: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1205 |
throw new IllegalStateException("Unhandled attribute: " + attrName); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1206 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1207 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1208 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1209 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1210 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1211 |
Object convertConstantValue(CPInfo info, String descriptor) throws ConstantPoolException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1212 |
if (info instanceof CONSTANT_Integer_info) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1213 |
if ("Z".equals(descriptor)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1214 |
return ((CONSTANT_Integer_info) info).value == 1; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1215 |
else |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1216 |
return ((CONSTANT_Integer_info) info).value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1217 |
} else if (info instanceof CONSTANT_Long_info) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1218 |
return ((CONSTANT_Long_info) info).value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1219 |
} else if (info instanceof CONSTANT_Float_info) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1220 |
return ((CONSTANT_Float_info) info).value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1221 |
} else if (info instanceof CONSTANT_Double_info) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1222 |
return ((CONSTANT_Double_info) info).value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1223 |
} else if (info instanceof CONSTANT_String_info) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1224 |
return ((CONSTANT_String_info) info).getString(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1225 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1226 |
throw new IllegalStateException(info.getClass().getName()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1227 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1228 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1229 |
Object convertElementValue(ConstantPool cp, element_value val) throws InvalidIndex, ConstantPoolException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1230 |
switch (val.tag) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1231 |
case 'Z': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1232 |
return ((CONSTANT_Integer_info) cp.get(((Primitive_element_value) val).const_value_index)).value != 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1233 |
case 'B': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1234 |
return (byte) ((CONSTANT_Integer_info) cp.get(((Primitive_element_value) val).const_value_index)).value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1235 |
case 'C': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1236 |
return (char) ((CONSTANT_Integer_info) cp.get(((Primitive_element_value) val).const_value_index)).value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1237 |
case 'S': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1238 |
return (short) ((CONSTANT_Integer_info) cp.get(((Primitive_element_value) val).const_value_index)).value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1239 |
case 'I': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1240 |
return ((CONSTANT_Integer_info) cp.get(((Primitive_element_value) val).const_value_index)).value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1241 |
case 'J': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1242 |
return ((CONSTANT_Long_info) cp.get(((Primitive_element_value) val).const_value_index)).value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1243 |
case 'F': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1244 |
return ((CONSTANT_Float_info) cp.get(((Primitive_element_value) val).const_value_index)).value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1245 |
case 'D': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1246 |
return ((CONSTANT_Double_info) cp.get(((Primitive_element_value) val).const_value_index)).value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1247 |
case 's': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1248 |
return ((CONSTANT_Utf8_info) cp.get(((Primitive_element_value) val).const_value_index)).value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1249 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1250 |
case 'e': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1251 |
return new EnumConstant(cp.getUTF8Value(((Enum_element_value) val).type_name_index), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1252 |
cp.getUTF8Value(((Enum_element_value) val).const_name_index)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1253 |
case 'c': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1254 |
return new ClassConstant(cp.getUTF8Value(((Class_element_value) val).class_info_index)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1255 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1256 |
case '@': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1257 |
return annotation2Description(cp, ((Annotation_element_value) val).annotation_value); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1258 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1259 |
case '[': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1260 |
List<Object> values = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1261 |
for (element_value elem : ((Array_element_value) val).values) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1262 |
values.add(convertElementValue(cp, elem)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1263 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1264 |
return values; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1265 |
default: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1266 |
throw new IllegalStateException("Currently unhandled tag: " + val.tag); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1267 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1268 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1269 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1270 |
private List<AnnotationDescription> annotations2Description(ConstantPool cp, Attribute attr) throws ConstantPoolException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1271 |
RuntimeAnnotations_attribute annotationsAttr = (RuntimeAnnotations_attribute) attr; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1272 |
List<AnnotationDescription> descs = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1273 |
for (Annotation a : annotationsAttr.annotations) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1274 |
descs.add(annotation2Description(cp, a)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1275 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1276 |
return descs; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1277 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1278 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1279 |
private List<List<AnnotationDescription>> parameterAnnotations2Description(ConstantPool cp, Attribute attr) throws ConstantPoolException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1280 |
RuntimeParameterAnnotations_attribute annotationsAttr = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1281 |
(RuntimeParameterAnnotations_attribute) attr; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1282 |
List<List<AnnotationDescription>> descs = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1283 |
for (Annotation[] attrAnnos : annotationsAttr.parameter_annotations) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1284 |
List<AnnotationDescription> paramDescs = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1285 |
for (Annotation ann : attrAnnos) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1286 |
paramDescs.add(annotation2Description(cp, ann)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1287 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1288 |
descs.add(paramDescs); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1289 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1290 |
return descs; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1291 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1292 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1293 |
private AnnotationDescription annotation2Description(ConstantPool cp, Annotation a) throws ConstantPoolException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1294 |
String annotationType = cp.getUTF8Value(a.type_index); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1295 |
Map<String, Object> values = new HashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1296 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1297 |
for (element_value_pair e : a.element_value_pairs) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1298 |
values.put(cp.getUTF8Value(e.element_name_index), convertElementValue(cp, e.value)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1299 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1300 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1301 |
return new AnnotationDescription(annotationType, values); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1302 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1303 |
//</editor-fold> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1304 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1305 |
protected boolean includeEffectiveAccess(ClassList classes, ClassDescription clazz) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1306 |
if (!include(clazz.header.get(0).flags)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1307 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1308 |
for (ClassDescription outer : classes.enclosingClasses(clazz)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1309 |
if (!include(outer.header.get(0).flags)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1310 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1311 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1312 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1313 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1314 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1315 |
boolean include(Set<String> includedClasses, ClassList classes, String clazzName) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1316 |
if (clazzName == null) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1317 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1318 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1319 |
boolean modified = includedClasses.add(clazzName); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1320 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1321 |
for (ClassDescription outer : classes.enclosingClasses(classes.find(clazzName, true))) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1322 |
modified |= includedClasses.add(outer.name); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1323 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1324 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1325 |
return modified; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1326 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1327 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1328 |
<T extends FeatureDescription> boolean includeOutputType(Iterable<T> features, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1329 |
Function<T, String> feature2Descriptor, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1330 |
Set<String> includedClasses, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1331 |
ClassList classes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1332 |
boolean modified = false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1333 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1334 |
for (T feature : features) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1335 |
CharSequence sig = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1336 |
feature.signature != null ? feature.signature : feature2Descriptor.apply(feature); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1337 |
Matcher m = OUTPUT_TYPE_PATTERN.matcher(sig); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1338 |
while (m.find()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1339 |
modified |= include(includedClasses, classes, m.group(1)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1340 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1341 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1342 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1343 |
return modified; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1344 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1345 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1346 |
static final Pattern OUTPUT_TYPE_PATTERN = Pattern.compile("L([^;<]+)(;|<)"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1347 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1348 |
Map<String, String> buildPackage2Modules(Path jdkRoot) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1349 |
if (jdkRoot == null) //in tests |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1350 |
return Collections.emptyMap(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1351 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1352 |
Map<String, String> result = new HashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1353 |
try (DirectoryStream<Path> repositories = Files.newDirectoryStream(jdkRoot)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1354 |
for (Path repository : repositories) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1355 |
Path src = repository.resolve("src"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1356 |
if (!Files.isDirectory(src)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1357 |
continue; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1358 |
try (DirectoryStream<Path> modules = Files.newDirectoryStream(src)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1359 |
for (Path module : modules) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1360 |
Path shareClasses = module.resolve("share/classes"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1361 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1362 |
if (!Files.isDirectory(shareClasses)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1363 |
continue; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1364 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1365 |
Set<String> packages = new HashSet<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1366 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1367 |
packages(shareClasses, new StringBuilder(), packages); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1368 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1369 |
for (String p : packages) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1370 |
if (result.containsKey(p)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1371 |
throw new IllegalStateException("Duplicate package mapping."); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1372 |
result.put(p, module.getFileName().toString()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1373 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1374 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1375 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1376 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1377 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1378 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1379 |
return result; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1380 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1381 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1382 |
void packages(Path dir, StringBuilder soFar, Set<String> packages) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1383 |
try (DirectoryStream<Path> c = Files.newDirectoryStream(dir)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1384 |
for (Path f : c) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1385 |
if (Files.isReadable(f) && f.getFileName().toString().endsWith(".java")) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1386 |
packages.add(soFar.toString()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1387 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1388 |
if (Files.isDirectory(f)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1389 |
int len = soFar.length(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1390 |
if (len > 0) soFar.append("."); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1391 |
soFar.append(f.getFileName().toString()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1392 |
packages(f, soFar, packages); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1393 |
soFar.delete(len, soFar.length()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1394 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1395 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1396 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1397 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1398 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1399 |
public static class VersionDescription { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1400 |
public final String classes; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1401 |
public final String version; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1402 |
public final String primaryBaseline; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1403 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1404 |
public VersionDescription(String classes, String version, String primaryBaseline) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1405 |
this.classes = classes; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1406 |
this.version = version; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1407 |
this.primaryBaseline = "<none>".equals(primaryBaseline) ? null : primaryBaseline; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1408 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1409 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1410 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1411 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1412 |
public static class ExcludeIncludeList { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1413 |
public final Set<String> includeList; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1414 |
public final Set<String> excludeList; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1415 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1416 |
protected ExcludeIncludeList(Set<String> includeList, Set<String> excludeList) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1417 |
this.includeList = includeList; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1418 |
this.excludeList = excludeList; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1419 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1420 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1421 |
public static ExcludeIncludeList create(String files) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1422 |
Set<String> includeList = new HashSet<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1423 |
Set<String> excludeList = new HashSet<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1424 |
for (String file : files.split(File.pathSeparator)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1425 |
try (Stream<String> lines = Files.lines(Paths.get(file))) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1426 |
lines.map(l -> l.substring(0, l.indexOf('#') != (-1) ? l.indexOf('#') : l.length())) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1427 |
.filter(l -> !l.trim().isEmpty()) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1428 |
.forEach(l -> { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1429 |
Set<String> target = l.startsWith("+") ? includeList : excludeList; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1430 |
target.add(l.substring(1)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1431 |
}); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1432 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1433 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1434 |
return new ExcludeIncludeList(includeList, excludeList); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1435 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1436 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1437 |
public boolean accepts(String className) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1438 |
return matches(includeList, className) && !matches(excludeList, className); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1439 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1440 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1441 |
private static boolean matches(Set<String> list, String className) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1442 |
if (list.contains(className)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1443 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1444 |
String pack = className.substring(0, className.lastIndexOf('/') + 1); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1445 |
return list.contains(pack); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1446 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1447 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1448 |
//</editor-fold> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1449 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1450 |
//<editor-fold defaultstate="collapsed" desc="Class Data Structures"> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1451 |
static abstract class FeatureDescription { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1452 |
int flags; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1453 |
boolean deprecated; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1454 |
String signature; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1455 |
String versions = ""; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1456 |
List<AnnotationDescription> classAnnotations; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1457 |
List<AnnotationDescription> runtimeAnnotations; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1458 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1459 |
protected void writeAttributes(Appendable output) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1460 |
if (flags != 0) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1461 |
output.append(" flags " + Integer.toHexString(flags)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1462 |
if (deprecated) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1463 |
output.append(" deprecated true"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1464 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1465 |
if (signature != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1466 |
output.append(" signature " + quote(signature, false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1467 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1468 |
if (classAnnotations != null && !classAnnotations.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1469 |
output.append(" classAnnotations "); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1470 |
for (AnnotationDescription a : classAnnotations) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1471 |
output.append(quote(a.toString(), false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1472 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1473 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1474 |
if (runtimeAnnotations != null && !runtimeAnnotations.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1475 |
output.append(" runtimeAnnotations "); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1476 |
for (AnnotationDescription a : runtimeAnnotations) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1477 |
output.append(quote(a.toString(), false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1478 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1479 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1480 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1481 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1482 |
protected boolean shouldIgnore(String baselineVersion, String version) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1483 |
return (!versions.contains(version) && |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1484 |
(baselineVersion == null || !versions.contains(baselineVersion))) || |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1485 |
(baselineVersion != null && |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1486 |
versions.contains(baselineVersion) && versions.contains(version)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1487 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1488 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1489 |
public abstract void write(Appendable output, String baselineVersion, String version) throws IOException; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1490 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1491 |
protected void readAttributes(LineBasedReader reader) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1492 |
String inFlags = reader.attributes.get("flags"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1493 |
if (inFlags != null && !inFlags.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1494 |
flags = Integer.parseInt(inFlags, 16); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1495 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1496 |
String inDeprecated = reader.attributes.get("deprecated"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1497 |
if ("true".equals(inDeprecated)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1498 |
deprecated = true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1499 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1500 |
signature = reader.attributes.get("signature"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1501 |
String inClassAnnotations = reader.attributes.get("classAnnotations"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1502 |
if (inClassAnnotations != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1503 |
classAnnotations = parseAnnotations(unquote(inClassAnnotations), new int[1]); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1504 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1505 |
String inRuntimeAnnotations = reader.attributes.get("runtimeAnnotations"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1506 |
if (inRuntimeAnnotations != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1507 |
runtimeAnnotations = parseAnnotations(unquote(inRuntimeAnnotations), new int[1]); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1508 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1509 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1510 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1511 |
public abstract boolean read(LineBasedReader reader) throws IOException; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1512 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1513 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1514 |
public int hashCode() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1515 |
int hash = 3; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1516 |
hash = 89 * hash + this.flags; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1517 |
hash = 89 * hash + (this.deprecated ? 1 : 0); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1518 |
hash = 89 * hash + Objects.hashCode(this.signature); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1519 |
hash = 89 * hash + listHashCode(this.classAnnotations); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1520 |
hash = 89 * hash + listHashCode(this.runtimeAnnotations); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1521 |
return hash; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1522 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1523 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1524 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1525 |
public boolean equals(Object obj) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1526 |
if (obj == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1527 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1528 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1529 |
if (getClass() != obj.getClass()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1530 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1531 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1532 |
final FeatureDescription other = (FeatureDescription) obj; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1533 |
if (this.flags != other.flags) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1534 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1535 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1536 |
if (this.deprecated != other.deprecated) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1537 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1538 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1539 |
if (!Objects.equals(this.signature, other.signature)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1540 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1541 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1542 |
if (!listEquals(this.classAnnotations, other.classAnnotations)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1543 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1544 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1545 |
if (!listEquals(this.runtimeAnnotations, other.runtimeAnnotations)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1546 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1547 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1548 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1549 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1550 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1551 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1552 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1553 |
public static class ClassDescription { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1554 |
String name; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1555 |
List<ClassHeaderDescription> header = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1556 |
List<MethodDescription> methods = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1557 |
List<FieldDescription> fields = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1558 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1559 |
public void write(Appendable output, String baselineVersion, String version) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1560 |
boolean inBaseline = false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1561 |
boolean inVersion = false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1562 |
for (ClassHeaderDescription chd : header) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1563 |
if (baselineVersion != null && chd.versions.contains(baselineVersion)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1564 |
inBaseline = true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1565 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1566 |
if (chd.versions.contains(version)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1567 |
inVersion = true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1568 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1569 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1570 |
if (!inVersion && !inBaseline) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1571 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1572 |
if (!inVersion) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1573 |
output.append("-class name " + name + "\n\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1574 |
return; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1575 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1576 |
boolean hasChange = hasChange(header, version, baselineVersion) || |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1577 |
hasChange(fields, version, baselineVersion) || |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1578 |
hasChange(methods, version, baselineVersion); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1579 |
if (!hasChange) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1580 |
return; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1581 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1582 |
output.append("class name " + name + "\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1583 |
for (ClassHeaderDescription header : header) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1584 |
header.write(output, baselineVersion, version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1585 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1586 |
for (FieldDescription field : fields) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1587 |
field.write(output, baselineVersion, version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1588 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1589 |
for (MethodDescription method : methods) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1590 |
method.write(output, baselineVersion, version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1591 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1592 |
output.append("\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1593 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1594 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1595 |
boolean hasChange(List<? extends FeatureDescription> hasChange, String version, String baselineVersion) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1596 |
return hasChange.stream() |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1597 |
.map(fd -> fd.versions) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1598 |
.anyMatch(versions -> versions.contains(version) ^ |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1599 |
(baselineVersion != null && |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1600 |
versions.contains(baselineVersion))); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1601 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1602 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1603 |
public void read(LineBasedReader reader, String baselineVersion, String version) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1604 |
if (!"class".equals(reader.lineKey)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1605 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1606 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1607 |
name = reader.attributes.get("name"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1608 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1609 |
reader.moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1610 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1611 |
OUTER: while (reader.hasNext()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1612 |
switch (reader.lineKey) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1613 |
case "header": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1614 |
removeVersion(header, h -> true, version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1615 |
ClassHeaderDescription chd = new ClassHeaderDescription(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1616 |
chd.read(reader); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1617 |
chd.versions = version; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1618 |
header.add(chd); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1619 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1620 |
case "field": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1621 |
FieldDescription field = new FieldDescription(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1622 |
field.read(reader); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1623 |
field.versions += version; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1624 |
fields.add(field); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1625 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1626 |
case "-field": { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1627 |
removeVersion(fields, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1628 |
f -> Objects.equals(f.name, reader.attributes.get("name")) && |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1629 |
Objects.equals(f.descriptor, reader.attributes.get("descriptor")), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1630 |
version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1631 |
reader.moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1632 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1633 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1634 |
case "method": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1635 |
MethodDescription method = new MethodDescription(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1636 |
method.read(reader); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1637 |
method.versions += version; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1638 |
methods.add(method); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1639 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1640 |
case "-method": { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1641 |
removeVersion(methods, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1642 |
m -> Objects.equals(m.name, reader.attributes.get("name")) && |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1643 |
Objects.equals(m.descriptor, reader.attributes.get("descriptor")), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1644 |
version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1645 |
reader.moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1646 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1647 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1648 |
case "class": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1649 |
case "-class": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1650 |
break OUTER; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1651 |
default: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1652 |
throw new IllegalStateException(reader.lineKey); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1653 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1654 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1655 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1656 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1657 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1658 |
static class ClassHeaderDescription extends FeatureDescription { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1659 |
String extendsAttr; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1660 |
List<String> implementsAttr; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1661 |
List<InnerClassInfo> innerClasses; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1662 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1663 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1664 |
public int hashCode() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1665 |
int hash = super.hashCode(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1666 |
hash = 17 * hash + Objects.hashCode(this.extendsAttr); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1667 |
hash = 17 * hash + Objects.hashCode(this.implementsAttr); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1668 |
hash = 17 * hash + Objects.hashCode(this.innerClasses); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1669 |
return hash; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1670 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1671 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1672 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1673 |
public boolean equals(Object obj) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1674 |
if (obj == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1675 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1676 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1677 |
if (!super.equals(obj)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1678 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1679 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1680 |
final ClassHeaderDescription other = (ClassHeaderDescription) obj; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1681 |
if (!Objects.equals(this.extendsAttr, other.extendsAttr)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1682 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1683 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1684 |
if (!Objects.equals(this.implementsAttr, other.implementsAttr)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1685 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1686 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1687 |
if (!listEquals(this.innerClasses, other.innerClasses)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1688 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1689 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1690 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1691 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1692 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1693 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1694 |
public void write(Appendable output, String baselineVersion, String version) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1695 |
if (!versions.contains(version) || |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1696 |
(baselineVersion != null && versions.contains(baselineVersion) && versions.contains(version))) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1697 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1698 |
output.append("header"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1699 |
if (extendsAttr != null) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1700 |
output.append(" extends " + extendsAttr); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1701 |
if (implementsAttr != null && !implementsAttr.isEmpty()) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1702 |
output.append(" implements " + serializeList(implementsAttr)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1703 |
writeAttributes(output); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1704 |
output.append("\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1705 |
if (innerClasses != null && !innerClasses.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1706 |
for (InnerClassInfo ici : innerClasses) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1707 |
output.append("innerclass"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1708 |
output.append(" innerClass " + ici.innerClass); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1709 |
output.append(" outerClass " + ici.outerClass); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1710 |
output.append(" innerClassName " + ici.innerClassName); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1711 |
output.append(" flags " + Integer.toHexString(ici.innerClassFlags)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1712 |
output.append("\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1713 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1714 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1715 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1716 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1717 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1718 |
public boolean read(LineBasedReader reader) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1719 |
if (!"header".equals(reader.lineKey)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1720 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1721 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1722 |
extendsAttr = reader.attributes.get("extends"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1723 |
implementsAttr = deserializeList(reader.attributes.get("implements")); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1724 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1725 |
readAttributes(reader); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1726 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1727 |
innerClasses = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1728 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1729 |
reader.moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1730 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1731 |
while ("innerclass".equals(reader.lineKey)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1732 |
InnerClassInfo info = new InnerClassInfo(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1733 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1734 |
info.innerClass = reader.attributes.get("innerClass"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1735 |
info.outerClass = reader.attributes.get("outerClass"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1736 |
info.innerClassName = reader.attributes.get("innerClassName"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1737 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1738 |
String inFlags = reader.attributes.get("flags"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1739 |
if (inFlags != null && !inFlags.isEmpty()) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1740 |
info.innerClassFlags = Integer.parseInt(inFlags, 16); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1741 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1742 |
innerClasses.add(info); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1743 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1744 |
reader.moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1745 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1746 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1747 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1748 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1749 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1750 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1751 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1752 |
static class MethodDescription extends FeatureDescription { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1753 |
String name; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1754 |
String descriptor; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1755 |
List<String> thrownTypes; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1756 |
Object annotationDefaultValue; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1757 |
List<List<AnnotationDescription>> classParameterAnnotations; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1758 |
List<List<AnnotationDescription>> runtimeParameterAnnotations; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1759 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1760 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1761 |
public int hashCode() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1762 |
int hash = super.hashCode(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1763 |
hash = 59 * hash + Objects.hashCode(this.name); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1764 |
hash = 59 * hash + Objects.hashCode(this.descriptor); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1765 |
hash = 59 * hash + Objects.hashCode(this.thrownTypes); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1766 |
hash = 59 * hash + Objects.hashCode(this.annotationDefaultValue); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1767 |
return hash; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1768 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1769 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1770 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1771 |
public boolean equals(Object obj) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1772 |
if (obj == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1773 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1774 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1775 |
if (!super.equals(obj)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1776 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1777 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1778 |
final MethodDescription other = (MethodDescription) obj; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1779 |
if (!Objects.equals(this.name, other.name)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1780 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1781 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1782 |
if (!Objects.equals(this.descriptor, other.descriptor)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1783 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1784 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1785 |
if (!Objects.equals(this.thrownTypes, other.thrownTypes)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1786 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1787 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1788 |
if (!Objects.equals(this.annotationDefaultValue, other.annotationDefaultValue)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1789 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1790 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1791 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1792 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1793 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1794 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1795 |
public void write(Appendable output, String baselineVersion, String version) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1796 |
if (shouldIgnore(baselineVersion, version)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1797 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1798 |
if (!versions.contains(version)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1799 |
output.append("-method"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1800 |
output.append(" name " + quote(name, false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1801 |
output.append(" descriptor " + quote(descriptor, false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1802 |
output.append("\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1803 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1804 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1805 |
output.append("method"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1806 |
output.append(" name " + quote(name, false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1807 |
output.append(" descriptor " + quote(descriptor, false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1808 |
if (thrownTypes != null) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1809 |
output.append(" thrownTypes " + serializeList(thrownTypes)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1810 |
if (annotationDefaultValue != null) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1811 |
output.append(" annotationDefaultValue " + quote(AnnotationDescription.dumpAnnotationValue(annotationDefaultValue), false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1812 |
writeAttributes(output); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1813 |
if (classParameterAnnotations != null && !classParameterAnnotations.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1814 |
output.append(" classParameterAnnotations "); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1815 |
for (List<AnnotationDescription> pa : classParameterAnnotations) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1816 |
for (AnnotationDescription a : pa) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1817 |
output.append(quote(a.toString(), false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1818 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1819 |
output.append(";"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1820 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1821 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1822 |
if (runtimeParameterAnnotations != null && !runtimeParameterAnnotations.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1823 |
output.append(" runtimeParameterAnnotations "); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1824 |
for (List<AnnotationDescription> pa : runtimeParameterAnnotations) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1825 |
for (AnnotationDescription a : pa) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1826 |
output.append(quote(a.toString(), false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1827 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1828 |
output.append(";"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1829 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1830 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1831 |
output.append("\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1832 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1833 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1834 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1835 |
public boolean read(LineBasedReader reader) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1836 |
if (!"method".equals(reader.lineKey)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1837 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1838 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1839 |
name = reader.attributes.get("name"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1840 |
descriptor = reader.attributes.get("descriptor"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1841 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1842 |
thrownTypes = deserializeList(reader.attributes.get("thrownTypes")); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1843 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1844 |
String inAnnotationDefaultValue = reader.attributes.get("annotationDefaultValue"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1845 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1846 |
if (inAnnotationDefaultValue != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1847 |
annotationDefaultValue = parseAnnotationValue(inAnnotationDefaultValue, new int[1]); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1848 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1849 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1850 |
readAttributes(reader); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1851 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1852 |
String inClassParamAnnotations = reader.attributes.get("classParameterAnnotations"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1853 |
if (inClassParamAnnotations != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1854 |
List<List<AnnotationDescription>> annos = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1855 |
int[] pointer = new int[1]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1856 |
do { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1857 |
annos.add(parseAnnotations(inClassParamAnnotations, pointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1858 |
assert pointer[0] == inClassParamAnnotations.length() || inClassParamAnnotations.charAt(pointer[0]) == ';'; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1859 |
} while (++pointer[0] < inClassParamAnnotations.length()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1860 |
classParameterAnnotations = annos; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1861 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1862 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1863 |
String inRuntimeParamAnnotations = reader.attributes.get("runtimeParameterAnnotations"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1864 |
if (inRuntimeParamAnnotations != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1865 |
List<List<AnnotationDescription>> annos = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1866 |
int[] pointer = new int[1]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1867 |
do { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1868 |
annos.add(parseAnnotations(inRuntimeParamAnnotations, pointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1869 |
assert pointer[0] == inRuntimeParamAnnotations.length() || inRuntimeParamAnnotations.charAt(pointer[0]) == ';'; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1870 |
} while (++pointer[0] < inRuntimeParamAnnotations.length()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1871 |
runtimeParameterAnnotations = annos; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1872 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1873 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1874 |
reader.moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1875 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1876 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1877 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1878 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1879 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1880 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1881 |
static class FieldDescription extends FeatureDescription { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1882 |
String name; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1883 |
String descriptor; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1884 |
Object constantValue; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1885 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1886 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1887 |
public int hashCode() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1888 |
int hash = super.hashCode(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1889 |
hash = 59 * hash + Objects.hashCode(this.name); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1890 |
hash = 59 * hash + Objects.hashCode(this.descriptor); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1891 |
hash = 59 * hash + Objects.hashCode(this.constantValue); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1892 |
return hash; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1893 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1894 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1895 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1896 |
public boolean equals(Object obj) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1897 |
if (obj == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1898 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1899 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1900 |
if (!super.equals(obj)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1901 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1902 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1903 |
final FieldDescription other = (FieldDescription) obj; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1904 |
if (!Objects.equals(this.name, other.name)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1905 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1906 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1907 |
if (!Objects.equals(this.descriptor, other.descriptor)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1908 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1909 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1910 |
if (!Objects.equals(this.constantValue, other.constantValue)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1911 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1912 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1913 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1914 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1915 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1916 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1917 |
public void write(Appendable output, String baselineVersion, String version) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1918 |
if (shouldIgnore(baselineVersion, version)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1919 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1920 |
if (!versions.contains(version)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1921 |
output.append("-field"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1922 |
output.append(" name " + quote(name, false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1923 |
output.append(" descriptor " + quote(descriptor, false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1924 |
output.append("\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1925 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1926 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1927 |
output.append("field"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1928 |
output.append(" name " + name); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1929 |
output.append(" descriptor " + descriptor); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1930 |
if (constantValue != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1931 |
output.append(" constantValue " + quote(constantValue.toString(), false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1932 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1933 |
writeAttributes(output); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1934 |
output.append("\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1935 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1936 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1937 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1938 |
public boolean read(LineBasedReader reader) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1939 |
if (!"field".equals(reader.lineKey)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1940 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1941 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1942 |
name = reader.attributes.get("name"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1943 |
descriptor = reader.attributes.get("descriptor"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1944 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1945 |
String inConstantValue = reader.attributes.get("constantValue"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1946 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1947 |
if (inConstantValue != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1948 |
switch (descriptor) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1949 |
case "Z": constantValue = "true".equals(inConstantValue); break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1950 |
case "B": constantValue = Byte.parseByte(inConstantValue); break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1951 |
case "C": constantValue = inConstantValue.charAt(0); break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1952 |
case "S": constantValue = Short.parseShort(inConstantValue); break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1953 |
case "I": constantValue = Integer.parseInt(inConstantValue); break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1954 |
case "J": constantValue = Long.parseLong(inConstantValue); break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1955 |
case "F": constantValue = Float.parseFloat(inConstantValue); break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1956 |
case "D": constantValue = Double.parseDouble(inConstantValue); break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1957 |
case "Ljava/lang/String;": constantValue = inConstantValue; break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1958 |
default: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1959 |
throw new IllegalStateException("Unrecognized field type: " + descriptor); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1960 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1961 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1962 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1963 |
readAttributes(reader); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1964 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1965 |
reader.moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1966 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1967 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1968 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1969 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1970 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1971 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1972 |
static final class AnnotationDescription { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1973 |
String annotationType; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1974 |
Map<String, Object> values; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1975 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1976 |
public AnnotationDescription(String annotationType, Map<String, Object> values) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1977 |
this.annotationType = annotationType; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1978 |
this.values = values; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1979 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1980 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1981 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1982 |
public int hashCode() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1983 |
int hash = 7; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1984 |
hash = 47 * hash + Objects.hashCode(this.annotationType); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1985 |
hash = 47 * hash + Objects.hashCode(this.values); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1986 |
return hash; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1987 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1988 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1989 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1990 |
public boolean equals(Object obj) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1991 |
if (obj == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1992 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1993 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1994 |
if (getClass() != obj.getClass()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1995 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1996 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1997 |
final AnnotationDescription other = (AnnotationDescription) obj; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1998 |
if (!Objects.equals(this.annotationType, other.annotationType)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1999 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2000 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2001 |
if (!Objects.equals(this.values, other.values)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2002 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2003 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2004 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2005 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2006 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2007 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2008 |
public String toString() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2009 |
StringBuilder result = new StringBuilder(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2010 |
result.append("@" + annotationType); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2011 |
if (!values.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2012 |
result.append("("); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2013 |
boolean first = true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2014 |
for (Entry<String, Object> e : values.entrySet()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2015 |
if (!first) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2016 |
result.append(","); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2017 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2018 |
first = false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2019 |
result.append(e.getKey()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2020 |
result.append("="); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2021 |
result.append(dumpAnnotationValue(e.getValue())); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2022 |
result.append(""); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2023 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2024 |
result.append(")"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2025 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2026 |
return result.toString(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2027 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2028 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2029 |
private static String dumpAnnotationValue(Object value) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2030 |
if (value instanceof List) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2031 |
StringBuilder result = new StringBuilder(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2032 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2033 |
result.append("{"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2034 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2035 |
for (Object element : ((List) value)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2036 |
result.append(dumpAnnotationValue(element)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2037 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2038 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2039 |
result.append("}"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2040 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2041 |
return result.toString(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2042 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2043 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2044 |
if (value instanceof String) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2045 |
return "\"" + quote((String) value, true) + "\""; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2046 |
} else if (value instanceof Boolean) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2047 |
return "Z" + value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2048 |
} else if (value instanceof Byte) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2049 |
return "B" + value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2050 |
} if (value instanceof Character) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2051 |
return "C" + value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2052 |
} if (value instanceof Short) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2053 |
return "S" + value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2054 |
} if (value instanceof Integer) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2055 |
return "I" + value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2056 |
} if (value instanceof Long) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2057 |
return "J" + value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2058 |
} if (value instanceof Float) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2059 |
return "F" + value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2060 |
} if (value instanceof Double) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2061 |
return "D" + value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2062 |
} else { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2063 |
return value.toString(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2064 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2065 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2066 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2067 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2068 |
static final class EnumConstant { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2069 |
String type; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2070 |
String constant; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2071 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2072 |
public EnumConstant(String type, String constant) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2073 |
this.type = type; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2074 |
this.constant = constant; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2075 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2076 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2077 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2078 |
public String toString() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2079 |
return "e" + type + constant + ";"; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2080 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2081 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2082 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2083 |
public int hashCode() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2084 |
int hash = 7; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2085 |
hash = 19 * hash + Objects.hashCode(this.type); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2086 |
hash = 19 * hash + Objects.hashCode(this.constant); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2087 |
return hash; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2088 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2089 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2090 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2091 |
public boolean equals(Object obj) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2092 |
if (obj == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2093 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2094 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2095 |
if (getClass() != obj.getClass()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2096 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2097 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2098 |
final EnumConstant other = (EnumConstant) obj; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2099 |
if (!Objects.equals(this.type, other.type)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2100 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2101 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2102 |
if (!Objects.equals(this.constant, other.constant)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2103 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2104 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2105 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2106 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2107 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2108 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2109 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2110 |
static final class ClassConstant { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2111 |
String type; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2112 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2113 |
public ClassConstant(String type) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2114 |
this.type = type; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2115 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2116 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2117 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2118 |
public String toString() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2119 |
return "c" + type; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2120 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2121 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2122 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2123 |
public int hashCode() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2124 |
int hash = 3; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2125 |
hash = 53 * hash + Objects.hashCode(this.type); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2126 |
return hash; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2127 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2128 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2129 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2130 |
public boolean equals(Object obj) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2131 |
if (obj == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2132 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2133 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2134 |
if (getClass() != obj.getClass()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2135 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2136 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2137 |
final ClassConstant other = (ClassConstant) obj; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2138 |
if (!Objects.equals(this.type, other.type)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2139 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2140 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2141 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2142 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2143 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2144 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2145 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2146 |
static final class InnerClassInfo { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2147 |
String innerClass; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2148 |
String outerClass; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2149 |
String innerClassName; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2150 |
int innerClassFlags; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2151 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2152 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2153 |
public int hashCode() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2154 |
int hash = 3; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2155 |
hash = 11 * hash + Objects.hashCode(this.innerClass); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2156 |
hash = 11 * hash + Objects.hashCode(this.outerClass); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2157 |
hash = 11 * hash + Objects.hashCode(this.innerClassName); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2158 |
hash = 11 * hash + Objects.hashCode(this.innerClassFlags); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2159 |
return hash; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2160 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2161 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2162 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2163 |
public boolean equals(Object obj) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2164 |
if (obj == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2165 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2166 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2167 |
if (getClass() != obj.getClass()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2168 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2169 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2170 |
final InnerClassInfo other = (InnerClassInfo) obj; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2171 |
if (!Objects.equals(this.innerClass, other.innerClass)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2172 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2173 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2174 |
if (!Objects.equals(this.outerClass, other.outerClass)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2175 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2176 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2177 |
if (!Objects.equals(this.innerClassName, other.innerClassName)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2178 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2179 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2180 |
if (!Objects.equals(this.innerClassFlags, other.innerClassFlags)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2181 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2182 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2183 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2184 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2185 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2186 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2187 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2188 |
public static final class ClassList implements Iterable<ClassDescription> { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2189 |
private final List<ClassDescription> classes = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2190 |
private final Map<String, ClassDescription> name2Class = new HashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2191 |
private final Map<ClassDescription, ClassDescription> inner2Outter = new HashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2192 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2193 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2194 |
public Iterator<ClassDescription> iterator() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2195 |
return classes.iterator(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2196 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2197 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2198 |
public void add(ClassDescription desc) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2199 |
classes.add(desc); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2200 |
name2Class.put(desc.name, desc); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2201 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2202 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2203 |
public ClassDescription find(String name) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2204 |
return find(name, ALLOW_NON_EXISTING_CLASSES); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2205 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2206 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2207 |
public ClassDescription find(String name, boolean allowNull) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2208 |
ClassDescription desc = name2Class.get(name); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2209 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2210 |
if (desc != null || allowNull) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2211 |
return desc; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2212 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2213 |
throw new IllegalStateException("Cannot find: " + name); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2214 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2215 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2216 |
private static final ClassDescription NONE = new ClassDescription(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2217 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2218 |
public ClassDescription enclosingClass(ClassDescription clazz) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2219 |
if (clazz == null) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2220 |
return null; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2221 |
ClassDescription desc = inner2Outter.computeIfAbsent(clazz, c -> { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2222 |
ClassHeaderDescription header = clazz.header.get(0); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2223 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2224 |
if (header.innerClasses != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2225 |
for (InnerClassInfo ici : header.innerClasses) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2226 |
if (ici.innerClass.equals(clazz.name)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2227 |
return find(ici.outerClass); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2228 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2229 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2230 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2231 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2232 |
return NONE; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2233 |
}); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2234 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2235 |
return desc != NONE ? desc : null; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2236 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2237 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2238 |
public Iterable<ClassDescription> enclosingClasses(ClassDescription clazz) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2239 |
List<ClassDescription> result = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2240 |
ClassDescription outer = enclosingClass(clazz); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2241 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2242 |
while (outer != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2243 |
result.add(outer); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2244 |
outer = enclosingClass(outer); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2245 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2246 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2247 |
return result; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2248 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2249 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2250 |
public void sort() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2251 |
Collections.sort(classes, (cd1, cd2) -> cd1.name.compareTo(cd2.name)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2252 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2253 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2254 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2255 |
private static int listHashCode(Collection<?> c) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2256 |
return c == null || c.isEmpty() ? 0 : c.hashCode(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2257 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2258 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2259 |
private static boolean listEquals(Collection<?> c1, Collection<?> c2) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2260 |
if (c1 == c2) return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2261 |
if (c1 == null && c2.isEmpty()) return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2262 |
if (c2 == null && c1.isEmpty()) return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2263 |
return Objects.equals(c1, c2); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2264 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2265 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2266 |
private static String serializeList(List<String> list) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2267 |
StringBuilder result = new StringBuilder(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2268 |
String sep = ""; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2269 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2270 |
for (Object o : list) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2271 |
result.append(sep); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2272 |
result.append(o); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2273 |
sep = ","; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2274 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2275 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2276 |
return quote(result.toString(), false); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2277 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2278 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2279 |
private static List<String> deserializeList(String serialized) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2280 |
serialized = unquote(serialized); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2281 |
if (serialized == null) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2282 |
return new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2283 |
return new ArrayList<>(Arrays.asList(serialized.split(","))); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2284 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2285 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2286 |
private static String quote(String value, boolean quoteQuotes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2287 |
StringBuilder result = new StringBuilder(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2288 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2289 |
for (char c : value.toCharArray()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2290 |
if (c <= 32 || c >= 127 || c == '\\' || (quoteQuotes && c == '"')) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2291 |
result.append("\\u" + String.format("%04X", (int) c) + ";"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2292 |
} else { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2293 |
result.append(c); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2294 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2295 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2296 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2297 |
return result.toString(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2298 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2299 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2300 |
private static final Pattern unicodePattern = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2301 |
Pattern.compile("\\\\u([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2302 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2303 |
private static String unquote(String value) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2304 |
if (value == null) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2305 |
return null; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2306 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2307 |
StringBuilder result = new StringBuilder(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2308 |
Matcher m = unicodePattern.matcher(value); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2309 |
int lastStart = 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2310 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2311 |
while (m.find(lastStart)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2312 |
result.append(value.substring(lastStart, m.start())); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2313 |
result.append((char) Integer.parseInt(m.group(1), 16)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2314 |
lastStart = m.end() + 1; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2315 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2316 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2317 |
result.append(value.substring(lastStart, value.length())); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2318 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2319 |
return result.toString(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2320 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2321 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2322 |
private static String readDigits(String value, int[] valuePointer) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2323 |
int start = valuePointer[0]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2324 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2325 |
if (value.charAt(valuePointer[0]) == '-') |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2326 |
valuePointer[0]++; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2327 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2328 |
while (valuePointer[0] < value.length() && Character.isDigit(value.charAt(valuePointer[0]))) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2329 |
valuePointer[0]++; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2330 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2331 |
return value.substring(start, valuePointer[0]); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2332 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2333 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2334 |
private static String className(String value, int[] valuePointer) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2335 |
int start = valuePointer[0]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2336 |
while (value.charAt(valuePointer[0]++) != ';') |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2337 |
; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2338 |
return value.substring(start, valuePointer[0]); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2339 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2340 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2341 |
private static Object parseAnnotationValue(String value, int[] valuePointer) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2342 |
switch (value.charAt(valuePointer[0]++)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2343 |
case 'Z': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2344 |
if ("true".equals(value.substring(valuePointer[0], valuePointer[0] + 4))) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2345 |
valuePointer[0] += 4; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2346 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2347 |
} else if ("false".equals(value.substring(valuePointer[0], valuePointer[0] + 5))) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2348 |
valuePointer[0] += 5; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2349 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2350 |
} else { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2351 |
throw new IllegalStateException("Unrecognized boolean structure: " + value); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2352 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2353 |
case 'B': return Byte.parseByte(readDigits(value, valuePointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2354 |
case 'C': return value.charAt(valuePointer[0]++); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2355 |
case 'S': return Short.parseShort(readDigits(value, valuePointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2356 |
case 'I': return Integer.parseInt(readDigits(value, valuePointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2357 |
case 'J': return Long.parseLong(readDigits(value, valuePointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2358 |
case 'F': return Float.parseFloat(readDigits(value, valuePointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2359 |
case 'D': return Double.parseDouble(readDigits(value, valuePointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2360 |
case 'c': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2361 |
return new ClassConstant(className(value, valuePointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2362 |
case 'e': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2363 |
return new EnumConstant(className(value, valuePointer), className(value, valuePointer).replaceFirst(";$", "")); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2364 |
case '{': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2365 |
List<Object> elements = new ArrayList<>(); //TODO: a good test for this would be highly desirable |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2366 |
while (value.charAt(valuePointer[0]) != '}') { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2367 |
elements.add(parseAnnotationValue(value, valuePointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2368 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2369 |
valuePointer[0]++; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2370 |
return elements; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2371 |
case '"': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2372 |
int start = valuePointer[0]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2373 |
while (value.charAt(valuePointer[0]) != '"') |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2374 |
valuePointer[0]++; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2375 |
return unquote(value.substring(start, valuePointer[0]++)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2376 |
case '@': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2377 |
return parseAnnotation(value, valuePointer); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2378 |
default: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2379 |
throw new IllegalStateException("Unrecognized signature type: " + value.charAt(valuePointer[0] - 1) + "; value=" + value); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2380 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2381 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2382 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2383 |
public static List<AnnotationDescription> parseAnnotations(String encoded, int[] pointer) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2384 |
ArrayList<AnnotationDescription> result = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2385 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2386 |
while (pointer[0] < encoded.length() && encoded.charAt(pointer[0]) == '@') { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2387 |
pointer[0]++; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2388 |
result.add(parseAnnotation(encoded, pointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2389 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2390 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2391 |
return result; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2392 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2393 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2394 |
private static AnnotationDescription parseAnnotation(String value, int[] valuePointer) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2395 |
String className = className(value, valuePointer); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2396 |
Map<String, Object> attribute2Value = new HashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2397 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2398 |
if (valuePointer[0] < value.length() && value.charAt(valuePointer[0]) == '(') { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2399 |
while (value.charAt(valuePointer[0]) != ')') { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2400 |
int nameStart = ++valuePointer[0]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2401 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2402 |
while (value.charAt(valuePointer[0]++) != '='); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2403 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2404 |
String name = value.substring(nameStart, valuePointer[0] - 1); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2405 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2406 |
attribute2Value.put(name, parseAnnotationValue(value, valuePointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2407 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2408 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2409 |
valuePointer[0]++; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2410 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2411 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2412 |
return new AnnotationDescription(className, attribute2Value); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2413 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2414 |
//</editor-fold> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2415 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2416 |
private static void help() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2417 |
System.err.println("Help..."); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2418 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2419 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2420 |
public static void main(String... args) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2421 |
if (args.length < 1) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2422 |
help(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2423 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2424 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2425 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2426 |
switch (args[0]) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2427 |
case "build-description": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2428 |
if (args.length < 4) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2429 |
help(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2430 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2431 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2432 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2433 |
Path descDest = Paths.get(args[1]); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2434 |
List<VersionDescription> versions = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2435 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2436 |
for (int i = 4; i + 2 < args.length; i += 3) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2437 |
versions.add(new VersionDescription(args[i + 1], args[i], args[i + 2])); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2438 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2439 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2440 |
Files.walkFileTree(descDest, new FileVisitor<Path>() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2441 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2442 |
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2443 |
return FileVisitResult.CONTINUE; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2444 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2445 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2446 |
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2447 |
Files.delete(file); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2448 |
return FileVisitResult.CONTINUE; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2449 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2450 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2451 |
public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2452 |
return FileVisitResult.CONTINUE; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2453 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2454 |
@Override public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2455 |
Files.delete(dir); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2456 |
return FileVisitResult.CONTINUE; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2457 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2458 |
}); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2459 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2460 |
new CreateSymbols().createBaseLine(versions, ExcludeIncludeList.create(args[3]), descDest, Paths.get(args[2])); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2461 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2462 |
case "build-ctsym": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2463 |
if (args.length < 3 || args.length > 4) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2464 |
help(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2465 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2466 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2467 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2468 |
CtSymKind createKind = CtSymKind.JOINED_VERSIONS; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2469 |
int argIndex = 1; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2470 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2471 |
if (args.length == 4) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2472 |
createKind = CtSymKind.valueOf(args[1]); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2473 |
argIndex++; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2474 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2475 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2476 |
new CreateSymbols().createSymbols(args[argIndex], args[argIndex + 1], createKind); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2477 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2478 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2479 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2480 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2481 |
} |