author | jlahoda |
Mon, 06 Nov 2017 14:10:39 +0100 | |
changeset 47703 | dbfac941197a |
parent 47216 | 71c04702a3d5 |
child 50027 | 69aadf0c1e69 |
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 |
|
47703 | 28 |
import build.tools.symbolgenerator.CreateSymbols |
29 |
.ModuleHeaderDescription |
|
30 |
.ProvidesDescription; |
|
31 |
import build.tools.symbolgenerator.CreateSymbols |
|
32 |
.ModuleHeaderDescription |
|
33 |
.RequiresDescription; |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
34 |
import java.io.BufferedReader; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
35 |
import java.io.ByteArrayInputStream; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
36 |
import java.io.ByteArrayOutputStream; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
37 |
import java.io.File; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
38 |
import java.io.IOException; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
39 |
import java.io.InputStream; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
40 |
import java.io.OutputStream; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
41 |
import java.io.Writer; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
42 |
import java.nio.file.DirectoryStream; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
43 |
import java.nio.file.Files; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
44 |
import java.nio.file.FileVisitResult; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
45 |
import java.nio.file.FileVisitor; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
46 |
import java.nio.file.Path; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
47 |
import java.nio.file.Paths; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
48 |
import java.nio.file.attribute.BasicFileAttributes; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
49 |
import java.util.stream.Stream; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
50 |
import java.util.ArrayList; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
51 |
import java.util.Arrays; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
52 |
import java.util.Collection; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
53 |
import java.util.Collections; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
54 |
import java.util.HashMap; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
55 |
import java.util.HashSet; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
56 |
import java.util.Iterator; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
57 |
import java.util.LinkedHashMap; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
58 |
import java.util.List; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
59 |
import java.util.Map; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
60 |
import java.util.Map.Entry; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
61 |
import java.util.Objects; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
62 |
import java.util.Set; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
63 |
import java.util.function.Function; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
64 |
import java.util.function.Predicate; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
65 |
import java.util.regex.Matcher; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
66 |
import java.util.regex.Pattern; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
67 |
import java.util.stream.Collectors; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
68 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
69 |
import com.sun.tools.classfile.AccessFlags; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
70 |
import com.sun.tools.classfile.Annotation; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
71 |
import com.sun.tools.classfile.Annotation.Annotation_element_value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
72 |
import com.sun.tools.classfile.Annotation.Array_element_value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
73 |
import com.sun.tools.classfile.Annotation.Class_element_value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
74 |
import com.sun.tools.classfile.Annotation.Enum_element_value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
75 |
import com.sun.tools.classfile.Annotation.Primitive_element_value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
76 |
import com.sun.tools.classfile.Annotation.element_value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
77 |
import com.sun.tools.classfile.Annotation.element_value_pair; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
78 |
import com.sun.tools.classfile.AnnotationDefault_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
79 |
import com.sun.tools.classfile.Attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
80 |
import com.sun.tools.classfile.Attributes; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
81 |
import com.sun.tools.classfile.ClassFile; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
82 |
import com.sun.tools.classfile.ClassWriter; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
83 |
import com.sun.tools.classfile.ConstantPool; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
84 |
import com.sun.tools.classfile.ConstantPool.CONSTANT_Class_info; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
85 |
import com.sun.tools.classfile.ConstantPool.CONSTANT_Double_info; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
86 |
import com.sun.tools.classfile.ConstantPool.CONSTANT_Float_info; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
87 |
import com.sun.tools.classfile.ConstantPool.CONSTANT_Integer_info; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
88 |
import com.sun.tools.classfile.ConstantPool.CONSTANT_Long_info; |
47703 | 89 |
import com.sun.tools.classfile.ConstantPool.CONSTANT_Module_info; |
90 |
import com.sun.tools.classfile.ConstantPool.CONSTANT_Package_info; |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
91 |
import com.sun.tools.classfile.ConstantPool.CONSTANT_String_info; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
92 |
import com.sun.tools.classfile.ConstantPool.CONSTANT_Utf8_info; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
93 |
import com.sun.tools.classfile.ConstantPool.CPInfo; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
94 |
import com.sun.tools.classfile.ConstantPool.InvalidIndex; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
95 |
import com.sun.tools.classfile.ConstantPoolException; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
96 |
import com.sun.tools.classfile.ConstantValue_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
97 |
import com.sun.tools.classfile.Deprecated_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
98 |
import com.sun.tools.classfile.Descriptor; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
99 |
import com.sun.tools.classfile.Exceptions_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
100 |
import com.sun.tools.classfile.Field; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
101 |
import com.sun.tools.classfile.InnerClasses_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
102 |
import com.sun.tools.classfile.InnerClasses_attribute.Info; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
103 |
import com.sun.tools.classfile.Method; |
47703 | 104 |
import com.sun.tools.classfile.ModuleResolution_attribute; |
105 |
import com.sun.tools.classfile.ModuleTarget_attribute; |
|
106 |
import com.sun.tools.classfile.Module_attribute; |
|
107 |
import com.sun.tools.classfile.Module_attribute.ExportsEntry; |
|
108 |
import com.sun.tools.classfile.Module_attribute.OpensEntry; |
|
109 |
import com.sun.tools.classfile.Module_attribute.ProvidesEntry; |
|
110 |
import com.sun.tools.classfile.Module_attribute.RequiresEntry; |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
111 |
import com.sun.tools.classfile.RuntimeAnnotations_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
112 |
import com.sun.tools.classfile.RuntimeInvisibleAnnotations_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
113 |
import com.sun.tools.classfile.RuntimeInvisibleParameterAnnotations_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
114 |
import com.sun.tools.classfile.RuntimeParameterAnnotations_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
115 |
import com.sun.tools.classfile.RuntimeVisibleAnnotations_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
116 |
import com.sun.tools.classfile.RuntimeVisibleParameterAnnotations_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
117 |
import com.sun.tools.classfile.Signature_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
118 |
import com.sun.tools.javac.jvm.Target; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
119 |
import com.sun.tools.javac.util.Assert; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
120 |
import com.sun.tools.javac.util.Pair; |
47703 | 121 |
import java.io.StringWriter; |
31506
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 |
/** |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
124 |
* 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
|
125 |
* * 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
|
126 |
* * 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
|
127 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
128 |
* 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
|
129 |
* 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
|
130 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
131 |
* 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
|
132 |
* generate platforms <platform-ids-to-generate separate with ':'> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
133 |
* 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
|
134 |
* 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
|
135 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
136 |
* 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
|
137 |
* 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
|
138 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
139 |
* 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
|
140 |
* <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
|
141 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
142 |
* 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
|
143 |
* will be written. |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
144 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
145 |
* 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
|
146 |
* 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
|
147 |
* <platform-id1> <target-file-for-platform1> "<none>" |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
148 |
* <platform-id2> <target-file-for-platform2> <diff-against-platform2> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
149 |
* <platform-id3> <target-file-for-platform3> <diff-against-platform3> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
150 |
* ... |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
151 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
152 |
* 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
|
153 |
* 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
|
154 |
* 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
|
155 |
* 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
|
156 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
157 |
* 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
|
158 |
* 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
|
159 |
* 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
|
160 |
* 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
|
161 |
* 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
|
162 |
* 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
|
163 |
* <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
|
164 |
* 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
|
165 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
166 |
* 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
|
167 |
* <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
|
168 |
* <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
|
169 |
* 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
|
170 |
* 8 OpenJDK8.classes '<none>' |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
171 |
* 7 OpenJDK7.classes 8 |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
172 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
173 |
* 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
|
174 |
*/ |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
175 |
public class CreateSymbols { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
176 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
177 |
//<editor-fold defaultstate="collapsed" desc="ct.sym construction"> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
178 |
/**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
|
179 |
* {@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
|
180 |
*/ |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
181 |
@SuppressWarnings("unchecked") |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
182 |
public void createSymbols(String ctDescriptionFile, String ctSymLocation, CtSymKind ctSymKind) throws IOException { |
47703 | 183 |
Pair<ClassList, List<ModuleDescription>> data = load(Paths.get(ctDescriptionFile)); |
184 |
||
185 |
splitHeaders(data.fst); |
|
186 |
||
187 |
for (ModuleDescription md : data.snd) { |
|
188 |
for (ModuleHeaderDescription mhd : md.header) { |
|
189 |
List<String> versionsList = |
|
190 |
Collections.singletonList(mhd.versions); |
|
191 |
writeModulesForVersions(ctSymLocation, |
|
192 |
md, |
|
193 |
mhd, |
|
194 |
versionsList); |
|
195 |
} |
|
196 |
} |
|
197 |
||
198 |
for (ClassDescription classDescription : data.fst) { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
199 |
for (ClassHeaderDescription header : classDescription.header) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
200 |
switch (ctSymKind) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
201 |
case JOINED_VERSIONS: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
202 |
Set<String> jointVersions = new HashSet<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
203 |
jointVersions.add(header.versions); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
204 |
limitJointVersion(jointVersions, classDescription.fields); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
205 |
limitJointVersion(jointVersions, classDescription.methods); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
206 |
writeClassesForVersions(ctSymLocation, classDescription, header, jointVersions); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
207 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
208 |
case SEPARATE: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
209 |
Set<String> versions = new HashSet<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
210 |
for (char v : header.versions.toCharArray()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
211 |
versions.add("" + v); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
212 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
213 |
writeClassesForVersions(ctSymLocation, classDescription, header, versions); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
214 |
break; |
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 |
} |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
220 |
public static String EXTENSION = ".sig"; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
221 |
|
47703 | 222 |
Pair<ClassList, List<ModuleDescription>> load(Path ctDescription) throws IOException { |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
223 |
List<PlatformInput> platforms = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
224 |
Set<String> generatePlatforms = null; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
225 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
226 |
try (LineBasedReader reader = new LineBasedReader(ctDescription)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
227 |
while (reader.hasNext()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
228 |
switch (reader.lineKey) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
229 |
case "generate": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
230 |
String[] platformsAttr = reader.attributes.get("platforms").split(":"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
231 |
generatePlatforms = new HashSet<>(Arrays.asList(platformsAttr)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
232 |
reader.moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
233 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
234 |
case "platform": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
235 |
platforms.add(PlatformInput.load(reader)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
236 |
reader.moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
237 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
238 |
default: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
239 |
throw new IllegalStateException("Unknown key: " + reader.lineKey); |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
244 |
Map<String, ClassDescription> classes = new LinkedHashMap<>(); |
47703 | 245 |
Map<String, ModuleDescription> modules = new LinkedHashMap<>(); |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
246 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
247 |
for (PlatformInput platform: platforms) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
248 |
for (ClassDescription cd : classes.values()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
249 |
addNewVersion(cd.header, platform.basePlatform, platform.version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
250 |
addNewVersion(cd.fields, platform.basePlatform, platform.version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
251 |
addNewVersion(cd.methods, platform.basePlatform, platform.version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
252 |
} |
47703 | 253 |
//XXX: enhance module versions |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
254 |
for (String input : platform.files) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
255 |
Path inputFile = ctDescription.getParent().resolve(input); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
256 |
try (LineBasedReader reader = new LineBasedReader(inputFile)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
257 |
while (reader.hasNext()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
258 |
String nameAttr = reader.attributes.get("name"); |
47703 | 259 |
switch (reader.lineKey) { |
260 |
case "class": case "-class": |
|
261 |
ClassDescription cd = |
|
262 |
classes.computeIfAbsent(nameAttr, |
|
263 |
n -> new ClassDescription()); |
|
264 |
if ("-class".equals(reader.lineKey)) { |
|
265 |
removeVersion(cd.header, h -> true, |
|
266 |
platform.version); |
|
267 |
reader.moveNext(); |
|
268 |
continue; |
|
269 |
} |
|
270 |
cd.read(reader, platform.basePlatform, |
|
271 |
platform.version); |
|
272 |
break; |
|
273 |
case "module": |
|
274 |
ModuleDescription md = |
|
275 |
modules.computeIfAbsent(nameAttr, |
|
276 |
n -> new ModuleDescription()); |
|
277 |
md.read(reader, platform.basePlatform, |
|
278 |
platform.version); |
|
279 |
break; |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
280 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
281 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
282 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
283 |
} |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
286 |
ClassList result = new ClassList(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
287 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
288 |
for (ClassDescription desc : classes.values()) { |
47703 | 289 |
Iterator<ClassHeaderDescription> chdIt = desc.header.iterator(); |
290 |
||
291 |
while (chdIt.hasNext()) { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
292 |
ClassHeaderDescription chd = chdIt.next(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
293 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
294 |
chd.versions = reduce(chd.versions, generatePlatforms); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
295 |
if (chd.versions.isEmpty()) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
296 |
chdIt.remove(); |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
299 |
if (desc.header.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
300 |
continue; |
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 |
|
47703 | 303 |
Iterator<MethodDescription> methodIt = desc.methods.iterator(); |
304 |
||
305 |
while (methodIt.hasNext()) { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
306 |
MethodDescription method = methodIt.next(); |
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 |
method.versions = reduce(method.versions, generatePlatforms); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
309 |
if (method.versions.isEmpty()) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
310 |
methodIt.remove(); |
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 |
|
47703 | 313 |
Iterator<FieldDescription> fieldIt = desc.fields.iterator(); |
314 |
||
315 |
while (fieldIt.hasNext()) { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
316 |
FieldDescription field = fieldIt.next(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
317 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
318 |
field.versions = reduce(field.versions, generatePlatforms); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
319 |
if (field.versions.isEmpty()) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
320 |
fieldIt.remove(); |
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 |
result.add(desc); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
324 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
325 |
|
47703 | 326 |
List<ModuleDescription> moduleList = new ArrayList<>(); |
327 |
||
328 |
for (ModuleDescription desc : modules.values()) { |
|
329 |
Iterator<ModuleHeaderDescription> mhdIt = desc.header.iterator(); |
|
330 |
||
331 |
while (mhdIt.hasNext()) { |
|
332 |
ModuleHeaderDescription mhd = mhdIt.next(); |
|
333 |
||
334 |
mhd.versions = reduce(mhd.versions, generatePlatforms); |
|
335 |
if (mhd.versions.isEmpty()) |
|
336 |
mhdIt.remove(); |
|
337 |
} |
|
338 |
||
339 |
if (desc.header.isEmpty()) { |
|
340 |
continue; |
|
341 |
} |
|
342 |
||
343 |
moduleList.add(desc); |
|
344 |
} |
|
345 |
||
346 |
return Pair.of(result, moduleList); |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
347 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
348 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
349 |
static final class LineBasedReader implements AutoCloseable { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
350 |
private final BufferedReader input; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
351 |
public String lineKey; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
352 |
public Map<String, String> attributes = new HashMap<>(); |
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 LineBasedReader(Path input) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
355 |
this.input = Files.newBufferedReader(input); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
356 |
moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
357 |
} |
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 |
public void moveNext() throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
360 |
String line = input.readLine(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
361 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
362 |
if (line == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
363 |
lineKey = null; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
364 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
365 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
366 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
367 |
if (line.trim().isEmpty() || line.startsWith("#")) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
368 |
moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
369 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
370 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
371 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
372 |
String[] parts = line.split(" "); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
373 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
374 |
lineKey = parts[0]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
375 |
attributes.clear(); |
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 |
for (int i = 1; i < parts.length; i += 2) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
378 |
attributes.put(parts[i], unquote(parts[i + 1])); |
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 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
381 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
382 |
public boolean hasNext() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
383 |
return lineKey != null; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
384 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
385 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
386 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
387 |
public void close() throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
388 |
input.close(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
389 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
390 |
} |
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 |
private static String reduce(String original, String other) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
393 |
Set<String> otherSet = new HashSet<>(); |
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 |
for (char v : other.toCharArray()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
396 |
otherSet.add("" + v); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
397 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
398 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
399 |
return reduce(original, otherSet); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
400 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
401 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
402 |
private static String reduce(String original, Set<String> generate) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
403 |
StringBuilder sb = new StringBuilder(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
404 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
405 |
for (char v : original.toCharArray()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
406 |
if (generate.contains("" + v)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
407 |
sb.append(v); |
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 |
return sb.toString(); |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
413 |
private static class PlatformInput { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
414 |
public final String version; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
415 |
public final String basePlatform; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
416 |
public final List<String> files; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
417 |
public PlatformInput(String version, String basePlatform, List<String> files) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
418 |
this.version = version; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
419 |
this.basePlatform = basePlatform; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
420 |
this.files = files; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
421 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
422 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
423 |
public static PlatformInput load(LineBasedReader in) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
424 |
return new PlatformInput(in.attributes.get("version"), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
425 |
in.attributes.get("base"), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
426 |
Arrays.asList(in.attributes.get("files").split(":"))); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
427 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
428 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
429 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
430 |
static void addNewVersion(Collection<? extends FeatureDescription> features, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
431 |
String baselineVersion, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
432 |
String version) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
433 |
features.stream() |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
434 |
.filter(f -> f.versions.contains(baselineVersion)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
435 |
.forEach(f -> f.versions += version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
436 |
} |
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 |
static <T extends FeatureDescription> void removeVersion(Collection<T> features, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
439 |
Predicate<T> shouldRemove, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
440 |
String version) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
441 |
for (T existing : features) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
442 |
if (shouldRemove.test(existing) && existing.versions.endsWith(version)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
443 |
existing.versions = existing.versions.replace(version, ""); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
444 |
return; |
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 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
447 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
448 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
449 |
/**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
|
450 |
* 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
|
451 |
* 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
|
452 |
*/ |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
453 |
static void splitHeaders(ClassList classes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
454 |
Set<String> ctVersions = new HashSet<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
455 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
456 |
for (ClassDescription cd : classes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
457 |
for (ClassHeaderDescription header : cd.header) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
458 |
for (char c : header.versions.toCharArray()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
459 |
ctVersions.add("" + c); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
460 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
461 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
462 |
} |
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 |
classes.sort(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
465 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
466 |
for (ClassDescription cd : classes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
467 |
Map<String, String> outerSignatures2Version = new HashMap<>(); |
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 |
for (String version : ctVersions) { //XXX |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
470 |
ClassDescription outer = cd; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
471 |
String outerSignatures = ""; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
472 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
473 |
while ((outer = classes.enclosingClass(outer)) != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
474 |
for (ClassHeaderDescription outerHeader : outer.header) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
475 |
if (outerHeader.versions.contains(version)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
476 |
outerSignatures += outerHeader.signature; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
477 |
} |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
481 |
outerSignatures2Version.compute(outerSignatures, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
482 |
(key, value) -> value != null ? value + version : version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
483 |
} |
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 |
List<ClassHeaderDescription> newHeaders = new ArrayList<>(); |
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 |
HEADER_LOOP: for (ClassHeaderDescription header : cd.header) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
488 |
for (String versions : outerSignatures2Version.values()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
489 |
if (containsAll(versions, header.versions)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
490 |
newHeaders.add(header); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
491 |
continue HEADER_LOOP; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
492 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
493 |
if (disjoint(versions, header.versions)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
494 |
continue; |
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 |
ClassHeaderDescription newHeader = new ClassHeaderDescription(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
497 |
newHeader.classAnnotations = header.classAnnotations; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
498 |
newHeader.deprecated = header.deprecated; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
499 |
newHeader.extendsAttr = header.extendsAttr; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
500 |
newHeader.flags = header.flags; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
501 |
newHeader.implementsAttr = header.implementsAttr; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
502 |
newHeader.innerClasses = header.innerClasses; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
503 |
newHeader.runtimeAnnotations = header.runtimeAnnotations; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
504 |
newHeader.signature = header.signature; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
505 |
newHeader.versions = reduce(versions, header.versions); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
506 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
507 |
newHeaders.add(newHeader); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
508 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
509 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
510 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
511 |
cd.header = newHeaders; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
512 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
513 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
514 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
515 |
void limitJointVersion(Set<String> jointVersions, List<? extends FeatureDescription> features) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
516 |
for (FeatureDescription feature : features) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
517 |
for (String version : jointVersions) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
518 |
if (!containsAll(feature.versions, version) && |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
519 |
!disjoint(feature.versions, version)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
520 |
StringBuilder featurePart = new StringBuilder(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
521 |
StringBuilder otherPart = new StringBuilder(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
522 |
for (char v : version.toCharArray()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
523 |
if (feature.versions.indexOf(v) != (-1)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
524 |
featurePart.append(v); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
525 |
} else { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
526 |
otherPart.append(v); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
527 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
528 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
529 |
jointVersions.remove(version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
530 |
if (featurePart.length() == 0 || otherPart.length() == 0) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
531 |
throw new AssertionError(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
532 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
533 |
jointVersions.add(featurePart.toString()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
534 |
jointVersions.add(otherPart.toString()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
535 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
536 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
537 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
538 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
539 |
} |
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 |
private static boolean containsAll(String versions, String subVersions) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
542 |
for (char c : subVersions.toCharArray()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
543 |
if (versions.indexOf(c) == (-1)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
544 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
545 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
546 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
547 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
548 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
549 |
private static boolean disjoint(String version1, String version2) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
550 |
for (char c : version2.toCharArray()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
551 |
if (version1.indexOf(c) != (-1)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
552 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
553 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
554 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
555 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
556 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
557 |
void writeClassesForVersions(String ctSymLocation, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
558 |
ClassDescription classDescription, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
559 |
ClassHeaderDescription header, |
47703 | 560 |
Iterable<String> versions) |
561 |
throws IOException { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
562 |
for (String ver : versions) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
563 |
writeClass(ctSymLocation, classDescription, header, ver); |
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 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
566 |
|
47703 | 567 |
void writeModulesForVersions(String ctSymLocation, |
568 |
ModuleDescription moduleDescription, |
|
569 |
ModuleHeaderDescription header, |
|
570 |
Iterable<String> versions) |
|
571 |
throws IOException { |
|
572 |
for (String ver : versions) { |
|
573 |
writeModule(ctSymLocation, moduleDescription, header, ver); |
|
574 |
} |
|
575 |
} |
|
576 |
||
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
577 |
public enum CtSymKind { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
578 |
JOINED_VERSIONS, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
579 |
SEPARATE; |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
582 |
//<editor-fold defaultstate="collapsed" desc="Class Writing"> |
47703 | 583 |
void writeModule(String ctSymLocation, |
584 |
ModuleDescription moduleDescription, |
|
585 |
ModuleHeaderDescription header, |
|
586 |
String version) throws IOException { |
|
587 |
List<CPInfo> constantPool = new ArrayList<>(); |
|
588 |
constantPool.add(null); |
|
589 |
int currentClass = addClass(constantPool, "module-info"); |
|
590 |
int superclass = 0; |
|
591 |
int[] interfaces = new int[0]; |
|
592 |
AccessFlags flags = new AccessFlags(header.flags); |
|
593 |
Map<String, Attribute> attributesMap = new HashMap<>(); |
|
594 |
addAttributes(moduleDescription, header, constantPool, attributesMap); |
|
595 |
Attributes attributes = new Attributes(attributesMap); |
|
596 |
CPInfo[] cpData = constantPool.toArray(new CPInfo[constantPool.size()]); |
|
597 |
ConstantPool cp = new ConstantPool(cpData); |
|
598 |
ClassFile classFile = new ClassFile(0xCAFEBABE, |
|
599 |
Target.DEFAULT.minorVersion, |
|
600 |
Target.DEFAULT.majorVersion, |
|
601 |
cp, |
|
602 |
flags, |
|
603 |
currentClass, |
|
604 |
superclass, |
|
605 |
interfaces, |
|
606 |
new Field[0], |
|
607 |
new Method[0], |
|
608 |
attributes); |
|
609 |
||
610 |
Path outputClassFile = Paths.get(ctSymLocation, |
|
611 |
version + "-modules", |
|
612 |
moduleDescription.name, |
|
613 |
"module-info" + EXTENSION); |
|
614 |
||
615 |
Files.createDirectories(outputClassFile.getParent()); |
|
616 |
||
617 |
try (OutputStream out = Files.newOutputStream(outputClassFile)) { |
|
618 |
ClassWriter w = new ClassWriter(); |
|
619 |
||
620 |
w.write(classFile, out); |
|
621 |
} |
|
622 |
} |
|
623 |
||
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
624 |
void writeClass(String ctSymLocation, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
625 |
ClassDescription classDescription, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
626 |
ClassHeaderDescription header, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
627 |
String version) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
628 |
List<CPInfo> constantPool = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
629 |
constantPool.add(null); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
630 |
List<Method> methods = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
631 |
for (MethodDescription methDesc : classDescription.methods) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
632 |
if (disjoint(methDesc.versions, version)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
633 |
continue; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
634 |
Descriptor descriptor = new Descriptor(addString(constantPool, methDesc.descriptor)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
635 |
//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
|
636 |
Map<String, Attribute> attributesMap = new LinkedHashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
637 |
addAttributes(methDesc, constantPool, attributesMap); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
638 |
Attributes attributes = new Attributes(attributesMap); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
639 |
AccessFlags flags = new AccessFlags(methDesc.flags); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
640 |
int nameString = addString(constantPool, methDesc.name); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
641 |
methods.add(new Method(flags, nameString, descriptor, attributes)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
642 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
643 |
List<Field> fields = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
644 |
for (FieldDescription fieldDesc : classDescription.fields) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
645 |
if (disjoint(fieldDesc.versions, version)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
646 |
continue; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
647 |
Descriptor descriptor = new Descriptor(addString(constantPool, fieldDesc.descriptor)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
648 |
Map<String, Attribute> attributesMap = new HashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
649 |
addAttributes(fieldDesc, constantPool, attributesMap); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
650 |
Attributes attributes = new Attributes(attributesMap); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
651 |
AccessFlags flags = new AccessFlags(fieldDesc.flags); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
652 |
int nameString = addString(constantPool, fieldDesc.name); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
653 |
fields.add(new Field(flags, nameString, descriptor, attributes)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
654 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
655 |
int currentClass = addClass(constantPool, classDescription.name); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
656 |
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
|
657 |
int[] interfaces = new int[header.implementsAttr.size()]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
658 |
int i = 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
659 |
for (String intf : header.implementsAttr) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
660 |
interfaces[i++] = addClass(constantPool, intf); |
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 |
AccessFlags flags = new AccessFlags(header.flags); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
663 |
Map<String, Attribute> attributesMap = new HashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
664 |
addAttributes(header, constantPool, attributesMap); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
665 |
Attributes attributes = new Attributes(attributesMap); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
666 |
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
|
667 |
ClassFile classFile = new ClassFile(0xCAFEBABE, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
668 |
Target.DEFAULT.minorVersion, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
669 |
Target.DEFAULT.majorVersion, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
670 |
cp, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
671 |
flags, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
672 |
currentClass, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
673 |
superclass, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
674 |
interfaces, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
675 |
fields.toArray(new Field[0]), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
676 |
methods.toArray(new Method[0]), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
677 |
attributes); |
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 |
Path outputClassFile = Paths.get(ctSymLocation, version, classDescription.name + EXTENSION); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
680 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
681 |
Files.createDirectories(outputClassFile.getParent()); |
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 |
try (OutputStream out = Files.newOutputStream(outputClassFile)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
684 |
ClassWriter w = new ClassWriter(); |
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 |
w.write(classFile, out); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
687 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
688 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
689 |
|
47703 | 690 |
private void addAttributes(ModuleDescription md, |
691 |
ModuleHeaderDescription header, |
|
692 |
List<CPInfo> cp, |
|
693 |
Map<String, Attribute> attributes) { |
|
694 |
addGenericAttributes(header, cp, attributes); |
|
695 |
if (header.moduleResolution != null) { |
|
696 |
int attrIdx = addString(cp, Attribute.ModuleResolution); |
|
697 |
final ModuleResolution_attribute resIdx = |
|
698 |
new ModuleResolution_attribute(attrIdx, |
|
699 |
header.moduleResolution); |
|
700 |
attributes.put(Attribute.ModuleResolution, resIdx); |
|
701 |
} |
|
702 |
if (header.moduleTarget != null) { |
|
703 |
int attrIdx = addString(cp, Attribute.ModuleTarget); |
|
704 |
int targetIdx = addString(cp, header.moduleTarget); |
|
705 |
attributes.put(Attribute.ModuleTarget, |
|
706 |
new ModuleTarget_attribute(attrIdx, targetIdx)); |
|
707 |
} |
|
708 |
int attrIdx = addString(cp, Attribute.Module); |
|
709 |
attributes.put(Attribute.Module, |
|
710 |
new Module_attribute(attrIdx, |
|
711 |
addModuleName(cp, md.name), |
|
712 |
0, |
|
713 |
0, |
|
714 |
header.requires |
|
715 |
.stream() |
|
716 |
.map(r -> createRequiresEntry(cp, r)) |
|
717 |
.collect(Collectors.toList()) |
|
718 |
.toArray(new RequiresEntry[0]), |
|
719 |
header.exports |
|
720 |
.stream() |
|
721 |
.map(e -> createExportsEntry(cp, e)) |
|
722 |
.collect(Collectors.toList()) |
|
723 |
.toArray(new ExportsEntry[0]), |
|
724 |
header.opens |
|
725 |
.stream() |
|
726 |
.map(e -> createOpensEntry(cp, e)) |
|
727 |
.collect(Collectors.toList()) |
|
728 |
.toArray(new OpensEntry[0]), |
|
729 |
header.uses |
|
730 |
.stream() |
|
731 |
.mapToInt(u -> addClassName(cp, u)) |
|
732 |
.toArray(), |
|
733 |
header.provides |
|
734 |
.stream() |
|
735 |
.map(p -> createProvidesEntry(cp, p)) |
|
736 |
.collect(Collectors.toList()) |
|
737 |
.toArray(new ProvidesEntry[0]))); |
|
738 |
addInnerClassesAttribute(header, cp, attributes); |
|
739 |
} |
|
740 |
||
741 |
private static RequiresEntry createRequiresEntry(List<CPInfo> cp, |
|
742 |
RequiresDescription r) { |
|
743 |
final int idx = addModuleName(cp, r.moduleName); |
|
744 |
return new RequiresEntry(idx, |
|
745 |
r.flags, |
|
746 |
r.version != null |
|
747 |
? addInt(cp, r.version) |
|
748 |
: 0); |
|
749 |
} |
|
750 |
||
751 |
private static ExportsEntry createExportsEntry(List<CPInfo> cp, |
|
752 |
String e) { |
|
753 |
return new ExportsEntry(addPackageName(cp, e), 0, new int[0]); |
|
754 |
} |
|
755 |
||
756 |
private static OpensEntry createOpensEntry(List<CPInfo> cp, String e) { |
|
757 |
return new OpensEntry(addPackageName(cp, e), 0, new int[0]); |
|
758 |
} |
|
759 |
||
760 |
private static ProvidesEntry createProvidesEntry(List<CPInfo> cp, |
|
761 |
ModuleHeaderDescription.ProvidesDescription p) { |
|
762 |
final int idx = addClassName(cp, p.interfaceName); |
|
763 |
return new ProvidesEntry(idx, p.implNames |
|
764 |
.stream() |
|
765 |
.mapToInt(i -> addClassName(cp, i)) |
|
766 |
.toArray()); |
|
767 |
} |
|
768 |
||
769 |
private void addAttributes(ClassHeaderDescription header, |
|
770 |
List<CPInfo> constantPool, Map<String, Attribute> attributes) { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
771 |
addGenericAttributes(header, constantPool, attributes); |
47703 | 772 |
addInnerClassesAttribute(header, constantPool, attributes); |
773 |
} |
|
774 |
||
775 |
private void addInnerClassesAttribute(HeaderDescription header, |
|
776 |
List<CPInfo> constantPool, Map<String, Attribute> attributes) { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
777 |
if (header.innerClasses != null && !header.innerClasses.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
778 |
Info[] innerClasses = new Info[header.innerClasses.size()]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
779 |
int i = 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
780 |
for (InnerClassInfo info : header.innerClasses) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
781 |
innerClasses[i++] = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
782 |
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
|
783 |
info.outerClass == null ? 0 : addClass(constantPool, info.outerClass), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
784 |
info.innerClassName == null ? 0 : addString(constantPool, info.innerClassName), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
785 |
new AccessFlags(info.innerClassFlags)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
786 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
787 |
int attributeString = addString(constantPool, Attribute.InnerClasses); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
788 |
attributes.put(Attribute.InnerClasses, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
789 |
new InnerClasses_attribute(attributeString, innerClasses)); |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
793 |
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
|
794 |
addGenericAttributes(desc, constantPool, attributes); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
795 |
if (desc.thrownTypes != null && !desc.thrownTypes.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
796 |
int[] exceptions = new int[desc.thrownTypes.size()]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
797 |
int i = 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
798 |
for (String exc : desc.thrownTypes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
799 |
exceptions[i++] = addClass(constantPool, exc); |
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 |
int attributeString = addString(constantPool, Attribute.Exceptions); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
802 |
attributes.put(Attribute.Exceptions, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
803 |
new Exceptions_attribute(attributeString, exceptions)); |
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 |
if (desc.annotationDefaultValue != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
806 |
int attributeString = addString(constantPool, Attribute.AnnotationDefault); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
807 |
element_value attributeValue = createAttributeValue(constantPool, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
808 |
desc.annotationDefaultValue); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
809 |
attributes.put(Attribute.AnnotationDefault, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
810 |
new AnnotationDefault_attribute(attributeString, attributeValue)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
811 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
812 |
if (desc.classParameterAnnotations != null && !desc.classParameterAnnotations.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
813 |
int attributeString = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
814 |
addString(constantPool, Attribute.RuntimeInvisibleParameterAnnotations); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
815 |
Annotation[][] annotations = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
816 |
createParameterAnnotations(constantPool, desc.classParameterAnnotations); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
817 |
attributes.put(Attribute.RuntimeInvisibleParameterAnnotations, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
818 |
new RuntimeInvisibleParameterAnnotations_attribute(attributeString, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
819 |
annotations)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
820 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
821 |
if (desc.runtimeParameterAnnotations != null && !desc.runtimeParameterAnnotations.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
822 |
int attributeString = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
823 |
addString(constantPool, Attribute.RuntimeVisibleParameterAnnotations); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
824 |
Annotation[][] annotations = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
825 |
createParameterAnnotations(constantPool, desc.runtimeParameterAnnotations); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
826 |
attributes.put(Attribute.RuntimeVisibleParameterAnnotations, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
827 |
new RuntimeVisibleParameterAnnotations_attribute(attributeString, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
828 |
annotations)); |
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 |
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
|
833 |
addGenericAttributes(desc, constantPool, attributes); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
834 |
if (desc.constantValue != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
835 |
Pair<Integer, Character> constantPoolEntry = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
836 |
addConstant(constantPool, desc.constantValue, false); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
837 |
Assert.checkNonNull(constantPoolEntry); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
838 |
int constantValueString = addString(constantPool, Attribute.ConstantValue); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
839 |
attributes.put(Attribute.ConstantValue, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
840 |
new ConstantValue_attribute(constantValueString, constantPoolEntry.fst)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
841 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
842 |
} |
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 |
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
|
845 |
if (desc.deprecated) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
846 |
int attributeString = addString(constantPool, Attribute.Deprecated); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
847 |
attributes.put(Attribute.Deprecated, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
848 |
new Deprecated_attribute(attributeString)); |
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 |
if (desc.signature != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
851 |
int attributeString = addString(constantPool, Attribute.Signature); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
852 |
int signatureString = addString(constantPool, desc.signature); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
853 |
attributes.put(Attribute.Signature, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
854 |
new Signature_attribute(attributeString, signatureString)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
855 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
856 |
if (desc.classAnnotations != null && !desc.classAnnotations.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
857 |
int attributeString = addString(constantPool, Attribute.RuntimeInvisibleAnnotations); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
858 |
Annotation[] annotations = createAnnotations(constantPool, desc.classAnnotations); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
859 |
attributes.put(Attribute.RuntimeInvisibleAnnotations, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
860 |
new RuntimeInvisibleAnnotations_attribute(attributeString, annotations)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
861 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
862 |
if (desc.runtimeAnnotations != null && !desc.runtimeAnnotations.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
863 |
int attributeString = addString(constantPool, Attribute.RuntimeVisibleAnnotations); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
864 |
Annotation[] annotations = createAnnotations(constantPool, desc.runtimeAnnotations); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
865 |
attributes.put(Attribute.RuntimeVisibleAnnotations, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
866 |
new RuntimeVisibleAnnotations_attribute(attributeString, annotations)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
867 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
868 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
869 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
870 |
private Annotation[] createAnnotations(List<CPInfo> constantPool, List<AnnotationDescription> desc) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
871 |
Annotation[] result = new Annotation[desc.size()]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
872 |
int i = 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 |
for (AnnotationDescription ad : desc) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
875 |
result[i++] = createAnnotation(constantPool, ad); |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
878 |
return result; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
879 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
880 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
881 |
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
|
882 |
Annotation[][] result = new Annotation[desc.size()][]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
883 |
int i = 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
884 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
885 |
for (List<AnnotationDescription> paramAnnos : desc) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
886 |
result[i++] = createAnnotations(constantPool, paramAnnos); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
887 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
888 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
889 |
return result; |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
892 |
private Annotation createAnnotation(List<CPInfo> constantPool, AnnotationDescription desc) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
893 |
return new Annotation(null, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
894 |
addString(constantPool, desc.annotationType), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
895 |
createElementPairs(constantPool, desc.values)); |
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 |
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
|
899 |
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
|
900 |
int i = 0; |
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 |
for (Entry<String, Object> e : annotationAttributes.entrySet()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
903 |
int elementNameString = addString(constantPool, e.getKey()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
904 |
element_value value = createAttributeValue(constantPool, e.getValue()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
905 |
pairs[i++] = new element_value_pair(elementNameString, value); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
906 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
907 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
908 |
return pairs; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
909 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
910 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
911 |
private element_value createAttributeValue(List<CPInfo> constantPool, Object value) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
912 |
Pair<Integer, Character> constantPoolEntry = addConstant(constantPool, value, true); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
913 |
if (constantPoolEntry != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
914 |
return new Primitive_element_value(constantPoolEntry.fst, constantPoolEntry.snd); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
915 |
} else if (value instanceof EnumConstant) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
916 |
EnumConstant ec = (EnumConstant) value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
917 |
return new Enum_element_value(addString(constantPool, ec.type), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
918 |
addString(constantPool, ec.constant), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
919 |
'e'); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
920 |
} else if (value instanceof ClassConstant) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
921 |
ClassConstant cc = (ClassConstant) value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
922 |
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
|
923 |
} else if (value instanceof AnnotationDescription) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
924 |
Annotation annotation = createAnnotation(constantPool, ((AnnotationDescription) value)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
925 |
return new Annotation_element_value(annotation, '@'); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
926 |
} else if (value instanceof Collection) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
927 |
@SuppressWarnings("unchecked") |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
928 |
Collection<Object> array = (Collection<Object>) value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
929 |
element_value[] values = new element_value[array.size()]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
930 |
int i = 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
931 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
932 |
for (Object elem : array) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
933 |
values[i++] = createAttributeValue(constantPool, elem); |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
936 |
return new Array_element_value(values, '['); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
937 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
938 |
throw new IllegalStateException(value.getClass().getName()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
939 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
940 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
941 |
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
|
942 |
if (value instanceof Boolean) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
943 |
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
|
944 |
} else if (value instanceof Byte) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
945 |
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
|
946 |
} else if (value instanceof Character) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
947 |
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
|
948 |
} else if (value instanceof Short) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
949 |
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
|
950 |
} else if (value instanceof Integer) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
951 |
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
|
952 |
} else if (value instanceof Long) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
953 |
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
|
954 |
} else if (value instanceof Float) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
955 |
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
|
956 |
} else if (value instanceof Double) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
957 |
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
|
958 |
} else if (value instanceof String) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
959 |
int stringIndex = addString(constantPool, (String) value); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
960 |
if (annotation) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
961 |
return Pair.of(stringIndex, 's'); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
962 |
} else { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
963 |
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
|
964 |
} |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
967 |
return null; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
968 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
969 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
970 |
private static int addString(List<CPInfo> constantPool, String string) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
971 |
Assert.checkNonNull(string); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
972 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
973 |
int i = 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
974 |
for (CPInfo info : constantPool) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
975 |
if (info instanceof CONSTANT_Utf8_info) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
976 |
if (((CONSTANT_Utf8_info) info).value.equals(string)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
977 |
return i; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
978 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
979 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
980 |
i++; |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
983 |
return addToCP(constantPool, new CONSTANT_Utf8_info(string)); |
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 |
|
47703 | 986 |
private static int addInt(List<CPInfo> constantPool, int value) { |
987 |
int i = 0; |
|
988 |
for (CPInfo info : constantPool) { |
|
989 |
if (info instanceof CONSTANT_Integer_info) { |
|
990 |
if (((CONSTANT_Integer_info) info).value == value) { |
|
991 |
return i; |
|
992 |
} |
|
993 |
} |
|
994 |
i++; |
|
995 |
} |
|
996 |
||
997 |
return addToCP(constantPool, new CONSTANT_Integer_info(value)); |
|
998 |
} |
|
999 |
||
1000 |
private static int addModuleName(List<CPInfo> constantPool, String moduleName) { |
|
1001 |
int nameIdx = addString(constantPool, moduleName); |
|
1002 |
int i = 0; |
|
1003 |
for (CPInfo info : constantPool) { |
|
1004 |
if (info instanceof CONSTANT_Module_info) { |
|
1005 |
if (((CONSTANT_Module_info) info).name_index == nameIdx) { |
|
1006 |
return i; |
|
1007 |
} |
|
1008 |
} |
|
1009 |
i++; |
|
1010 |
} |
|
1011 |
||
1012 |
return addToCP(constantPool, new CONSTANT_Module_info(null, nameIdx)); |
|
1013 |
} |
|
1014 |
||
1015 |
private static int addPackageName(List<CPInfo> constantPool, String packageName) { |
|
1016 |
int nameIdx = addString(constantPool, packageName); |
|
1017 |
int i = 0; |
|
1018 |
for (CPInfo info : constantPool) { |
|
1019 |
if (info instanceof CONSTANT_Package_info) { |
|
1020 |
if (((CONSTANT_Package_info) info).name_index == nameIdx) { |
|
1021 |
return i; |
|
1022 |
} |
|
1023 |
} |
|
1024 |
i++; |
|
1025 |
} |
|
1026 |
||
1027 |
return addToCP(constantPool, new CONSTANT_Package_info(null, nameIdx)); |
|
1028 |
} |
|
1029 |
||
1030 |
private static int addClassName(List<CPInfo> constantPool, String className) { |
|
1031 |
int nameIdx = addString(constantPool, className); |
|
1032 |
int i = 0; |
|
1033 |
for (CPInfo info : constantPool) { |
|
1034 |
if (info instanceof CONSTANT_Class_info) { |
|
1035 |
if (((CONSTANT_Class_info) info).name_index == nameIdx) { |
|
1036 |
return i; |
|
1037 |
} |
|
1038 |
} |
|
1039 |
i++; |
|
1040 |
} |
|
1041 |
||
1042 |
return addToCP(constantPool, new CONSTANT_Class_info(null, nameIdx)); |
|
1043 |
} |
|
1044 |
||
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1045 |
private static int addToCP(List<CPInfo> constantPool, CPInfo entry) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1046 |
int result = constantPool.size(); |
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 |
constantPool.add(entry); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1049 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1050 |
if (entry.size() > 1) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1051 |
constantPool.add(null); |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1054 |
return result; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1055 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1056 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1057 |
private static int addClass(List<CPInfo> constantPool, String className) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1058 |
int classNameIndex = addString(constantPool, className); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1059 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1060 |
int i = 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1061 |
for (CPInfo info : constantPool) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1062 |
if (info instanceof CONSTANT_Class_info) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1063 |
if (((CONSTANT_Class_info) info).name_index == classNameIndex) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1064 |
return i; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1065 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1066 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1067 |
i++; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1068 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1069 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1070 |
return addToCP(constantPool, new CONSTANT_Class_info(null, classNameIndex)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1071 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1072 |
//</editor-fold> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1073 |
//</editor-fold> |
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 |
//<editor-fold defaultstate="collapsed" desc="Create Symbol Description"> |
47703 | 1076 |
public void createBaseLine(List<VersionDescription> versions, |
1077 |
ExcludeIncludeList excludesIncludes, |
|
1078 |
Path descDest, |
|
1079 |
String[] args) throws IOException { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1080 |
ClassList classes = new ClassList(); |
47703 | 1081 |
Map<String, ModuleDescription> modules = new HashMap<>(); |
31506
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 |
for (VersionDescription desc : versions) { |
47703 | 1084 |
Map<String, ModuleDescription> currentVersionModules = |
1085 |
new HashMap<>(); |
|
1086 |
try (BufferedReader descIn = |
|
1087 |
Files.newBufferedReader(Paths.get(desc.classes))) { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1088 |
String classFileData; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1089 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1090 |
while ((classFileData = descIn.readLine()) != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1091 |
ByteArrayOutputStream data = new ByteArrayOutputStream(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1092 |
for (int i = 0; i < classFileData.length(); i += 2) { |
47703 | 1093 |
String hex = classFileData.substring(i, i + 2); |
1094 |
data.write(Integer.parseInt(hex, 16)); |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1095 |
} |
47703 | 1096 |
try (InputStream in = |
1097 |
new ByteArrayInputStream(data.toByteArray())) { |
|
1098 |
inspectModuleInfoClassFile(in, |
|
1099 |
currentVersionModules, desc.version); |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1100 |
} catch (IOException | ConstantPoolException ex) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1101 |
throw new IllegalStateException(ex); |
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 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1105 |
|
47703 | 1106 |
ExcludeIncludeList currentEIList = excludesIncludes; |
1107 |
||
1108 |
if (!currentVersionModules.isEmpty()) { |
|
1109 |
Set<String> includes = new HashSet<>(); |
|
1110 |
||
1111 |
for (ModuleDescription md : currentVersionModules.values()) { |
|
1112 |
md.header.get(0).exports.stream().map(e -> e + '/') |
|
1113 |
.forEach(includes::add); |
|
1114 |
} |
|
1115 |
||
1116 |
currentEIList = new ExcludeIncludeList(includes, |
|
1117 |
Collections.emptySet()); |
|
1118 |
} |
|
1119 |
||
1120 |
ClassList currentVersionClasses = new ClassList(); |
|
1121 |
try (BufferedReader descIn = |
|
1122 |
Files.newBufferedReader(Paths.get(desc.classes))) { |
|
1123 |
String classFileData; |
|
1124 |
||
1125 |
while ((classFileData = descIn.readLine()) != null) { |
|
1126 |
ByteArrayOutputStream data = new ByteArrayOutputStream(); |
|
1127 |
for (int i = 0; i < classFileData.length(); i += 2) { |
|
1128 |
String hex = classFileData.substring(i, i + 2); |
|
1129 |
data.write(Integer.parseInt(hex, 16)); |
|
1130 |
} |
|
1131 |
try (InputStream in = |
|
1132 |
new ByteArrayInputStream(data.toByteArray())) { |
|
1133 |
inspectClassFile(in, currentVersionClasses, |
|
1134 |
currentEIList, desc.version); |
|
1135 |
} catch (IOException | ConstantPoolException ex) { |
|
1136 |
throw new IllegalStateException(ex); |
|
1137 |
} |
|
1138 |
} |
|
1139 |
} |
|
1140 |
||
1141 |
ModuleDescription unsupported = |
|
1142 |
currentVersionModules.get("jdk.unsupported"); |
|
1143 |
||
1144 |
if (unsupported != null) { |
|
1145 |
for (ClassDescription cd : currentVersionClasses.classes) { |
|
1146 |
if (unsupported.header |
|
1147 |
.get(0) |
|
1148 |
.exports |
|
1149 |
.contains(cd.packge().replace('.', '/'))) { |
|
1150 |
ClassHeaderDescription ch = cd.header.get(0); |
|
1151 |
if (ch.classAnnotations == null) { |
|
1152 |
ch.classAnnotations = new ArrayList<>(); |
|
1153 |
} |
|
1154 |
AnnotationDescription ad; |
|
1155 |
ad = new AnnotationDescription(PROPERITARY_ANNOTATION, |
|
1156 |
Collections.emptyMap()); |
|
1157 |
ch.classAnnotations.add(ad); |
|
1158 |
} |
|
1159 |
} |
|
1160 |
} |
|
1161 |
||
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1162 |
Set<String> includedClasses = new HashSet<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1163 |
boolean modified; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1164 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1165 |
do { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1166 |
modified = false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1167 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1168 |
for (ClassDescription clazz : currentVersionClasses) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1169 |
ClassHeaderDescription header = clazz.header.get(0); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1170 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1171 |
if (includeEffectiveAccess(currentVersionClasses, clazz)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1172 |
modified |= include(includedClasses, currentVersionClasses, clazz.name); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1173 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1174 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1175 |
if (includedClasses.contains(clazz.name)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1176 |
modified |= include(includedClasses, currentVersionClasses, header.extendsAttr); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1177 |
for (String i : header.implementsAttr) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1178 |
modified |= include(includedClasses, currentVersionClasses, i); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1179 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1180 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1181 |
modified |= includeOutputType(Collections.singleton(header), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1182 |
h -> "", |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1183 |
includedClasses, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1184 |
currentVersionClasses); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1185 |
modified |= includeOutputType(clazz.fields, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1186 |
f -> f.descriptor, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1187 |
includedClasses, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1188 |
currentVersionClasses); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1189 |
modified |= includeOutputType(clazz.methods, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1190 |
m -> m.descriptor, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1191 |
includedClasses, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1192 |
currentVersionClasses); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1193 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1194 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1195 |
} while (modified); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1196 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1197 |
for (ClassDescription clazz : currentVersionClasses) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1198 |
if (!includedClasses.contains(clazz.name)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1199 |
continue; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1200 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1201 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1202 |
ClassHeaderDescription header = clazz.header.get(0); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1203 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1204 |
if (header.innerClasses != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1205 |
Iterator<InnerClassInfo> innerClassIt = header.innerClasses.iterator(); |
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 |
while(innerClassIt.hasNext()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1208 |
InnerClassInfo ici = innerClassIt.next(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1209 |
if (!includedClasses.contains(ici.innerClass)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1210 |
innerClassIt.remove(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1211 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1212 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1213 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1214 |
ClassDescription existing = classes.find(clazz.name, true); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1215 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1216 |
if (existing != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1217 |
addClassHeader(existing, header, desc.version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1218 |
for (MethodDescription currentMethod : clazz.methods) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1219 |
addMethod(existing, currentMethod, desc.version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1220 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1221 |
for (FieldDescription currentField : clazz.fields) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1222 |
addField(existing, currentField, desc.version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1223 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1224 |
} else { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1225 |
classes.add(clazz); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1226 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1227 |
} |
47703 | 1228 |
|
1229 |
for (ModuleDescription module : currentVersionModules.values()) { |
|
1230 |
ModuleHeaderDescription header = module.header.get(0); |
|
1231 |
||
1232 |
if (header.innerClasses != null) { |
|
1233 |
Iterator<InnerClassInfo> innerClassIt = |
|
1234 |
header.innerClasses.iterator(); |
|
1235 |
||
1236 |
while(innerClassIt.hasNext()) { |
|
1237 |
InnerClassInfo ici = innerClassIt.next(); |
|
1238 |
if (!includedClasses.contains(ici.innerClass)) |
|
1239 |
innerClassIt.remove(); |
|
1240 |
} |
|
1241 |
} |
|
1242 |
||
1243 |
ModuleDescription existing = modules.get(module.name); |
|
1244 |
||
1245 |
if (existing != null) { |
|
1246 |
addModuleHeader(existing, header, desc.version); |
|
1247 |
} else { |
|
1248 |
modules.put(module.name, module); |
|
1249 |
} |
|
1250 |
} |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1251 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1252 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1253 |
classes.sort(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1254 |
|
47703 | 1255 |
Map<String, String> package2Modules = new HashMap<>(); |
1256 |
||
1257 |
for (ModuleDescription md : modules.values()) { |
|
1258 |
md.header |
|
1259 |
.stream() |
|
1260 |
.filter(h -> h.versions.contains("9")) |
|
1261 |
.flatMap(h -> h.exports.stream()) |
|
1262 |
.map(p -> p.replace('/', '.')) |
|
1263 |
.forEach(p -> package2Modules.put(p, md.name)); |
|
1264 |
} |
|
1265 |
||
1266 |
package2Modules.put("java.awt.dnd.peer", "java.desktop"); |
|
1267 |
package2Modules.put("java.awt.peer", "java.desktop"); |
|
1268 |
package2Modules.put("jdk", "java.base"); |
|
1269 |
||
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1270 |
Map<String, List<ClassDescription>> module2Classes = new HashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1271 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1272 |
for (ClassDescription clazz : classes) { |
47703 | 1273 |
String pack = clazz.packge(); |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1274 |
String module = package2Modules.get(pack); |
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 |
if (module == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1277 |
module = "java.base"; |
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 |
OUTER: while (!pack.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1280 |
for (Entry<String, String> p2M : package2Modules.entrySet()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1281 |
if (p2M.getKey().startsWith(pack)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1282 |
module = p2M.getValue(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1283 |
break OUTER; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1284 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1285 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1286 |
int dot = pack.lastIndexOf('.'); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1287 |
if (dot == (-1)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1288 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1289 |
pack = pack.substring(0, dot); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1290 |
} |
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 |
module2Classes.computeIfAbsent(module, m -> new ArrayList<>()) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1293 |
.add(clazz); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1294 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1295 |
|
47703 | 1296 |
modules.keySet() |
1297 |
.stream() |
|
1298 |
.filter(m -> !module2Classes.containsKey(m)) |
|
1299 |
.forEach(m -> module2Classes.put(m, Collections.emptyList())); |
|
1300 |
||
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1301 |
Path symbolsFile = descDest.resolve("symbols"); |
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 |
Files.createDirectories(symbolsFile.getParent()); |
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 |
try (Writer symbolsOut = Files.newBufferedWriter(symbolsFile)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1306 |
Map<VersionDescription, List<Path>> outputFiles = new LinkedHashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1307 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1308 |
for (Entry<String, List<ClassDescription>> e : module2Classes.entrySet()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1309 |
for (VersionDescription desc : versions) { |
47703 | 1310 |
StringWriter data = new StringWriter(); |
1311 |
ModuleDescription module = modules.get(e.getKey()); |
|
1312 |
||
1313 |
module.write(data, desc.primaryBaseline, desc.version); |
|
1314 |
||
1315 |
for (ClassDescription clazz : e.getValue()) { |
|
1316 |
clazz.write(data, desc.primaryBaseline, desc.version); |
|
1317 |
} |
|
1318 |
||
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1319 |
Path f = descDest.resolve(e.getKey() + "-" + desc.version + ".sym.txt"); |
47703 | 1320 |
|
1321 |
String dataString = data.toString(); |
|
1322 |
||
1323 |
if (!dataString.isEmpty()) { |
|
1324 |
try (Writer out = Files.newBufferedWriter(f)) { |
|
1325 |
out.append(DO_NO_MODIFY); |
|
1326 |
out.write(dataString); |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1327 |
} |
47703 | 1328 |
|
1329 |
outputFiles.computeIfAbsent(desc, d -> new ArrayList<>()) |
|
1330 |
.add(f); |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1331 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1332 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1333 |
} |
47703 | 1334 |
symbolsOut.append(DO_NO_MODIFY); |
1335 |
symbolsOut.append("#command used to generate this file:\n"); |
|
1336 |
symbolsOut.append("#") |
|
1337 |
.append(CreateSymbols.class.getName()) |
|
1338 |
.append(" ") |
|
1339 |
.append(Arrays.asList(args) |
|
1340 |
.stream() |
|
1341 |
.collect(Collectors.joining(" "))) |
|
1342 |
.append("\n"); |
|
1343 |
symbolsOut.append("#\n"); |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1344 |
symbolsOut.append("generate platforms ") |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1345 |
.append(versions.stream() |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1346 |
.map(v -> v.version) |
47703 | 1347 |
.sorted() |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1348 |
.collect(Collectors.joining(":"))) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1349 |
.append("\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1350 |
for (Entry<VersionDescription, List<Path>> versionFileEntry : outputFiles.entrySet()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1351 |
symbolsOut.append("platform version ") |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1352 |
.append(versionFileEntry.getKey().version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1353 |
if (versionFileEntry.getKey().primaryBaseline != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1354 |
symbolsOut.append(" base ") |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1355 |
.append(versionFileEntry.getKey().primaryBaseline); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1356 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1357 |
symbolsOut.append(" files ") |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1358 |
.append(versionFileEntry.getValue() |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1359 |
.stream() |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1360 |
.map(p -> p.getFileName().toString()) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1361 |
.sorted() |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1362 |
.collect(Collectors.joining(":"))) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1363 |
.append("\n"); |
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 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1366 |
} |
47703 | 1367 |
//where: |
1368 |
private static final String DO_NO_MODIFY = |
|
1369 |
"# ##########################################################\n" + |
|
1370 |
"# ### THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. ###\n" + |
|
1371 |
"# ##########################################################\n" + |
|
1372 |
"#\n"; |
|
1373 |
private static final String PROPERITARY_ANNOTATION = |
|
1374 |
"Lsun/Proprietary+Annotation;"; |
|
31506
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 |
//<editor-fold defaultstate="collapsed" desc="Class Reading"> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1377 |
//non-final for tests: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1378 |
public static String PROFILE_ANNOTATION = "Ljdk/Profile+Annotation;"; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1379 |
public static boolean ALLOW_NON_EXISTING_CLASSES = false; |
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 |
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
|
1382 |
ClassFile cf = ClassFile.read(in); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1383 |
|
47703 | 1384 |
if (cf.access_flags.is(AccessFlags.ACC_MODULE)) { |
1385 |
return ; |
|
1386 |
} |
|
1387 |
||
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1388 |
if (!excludesIncludes.accepts(cf.getName())) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1389 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1390 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1391 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1392 |
ClassHeaderDescription headerDesc = new ClassHeaderDescription(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1393 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1394 |
headerDesc.flags = cf.access_flags.flags; |
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 |
if (cf.super_class != 0) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1397 |
headerDesc.extendsAttr = cf.getSuperclassName(); |
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 |
List<String> interfaces = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1400 |
for (int i = 0; i < cf.interfaces.length; i++) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1401 |
interfaces.add(cf.getInterfaceName(i)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1402 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1403 |
headerDesc.implementsAttr = interfaces; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1404 |
for (Attribute attr : cf.attributes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1405 |
if (!readAttribute(cf, headerDesc, attr)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1406 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1407 |
} |
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 |
ClassDescription clazzDesc = null; |
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 |
for (ClassDescription cd : classes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1412 |
if (cd.name.equals(cf.getName())) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1413 |
clazzDesc = cd; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1414 |
break; |
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 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1417 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1418 |
if (clazzDesc == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1419 |
clazzDesc = new ClassDescription(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1420 |
clazzDesc.name = cf.getName(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1421 |
classes.add(clazzDesc); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1422 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1423 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1424 |
addClassHeader(clazzDesc, headerDesc, version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1425 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1426 |
for (Method m : cf.methods) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1427 |
if (!include(m.access_flags.flags)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1428 |
continue; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1429 |
MethodDescription methDesc = new MethodDescription(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1430 |
methDesc.flags = m.access_flags.flags; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1431 |
methDesc.name = m.getName(cf.constant_pool); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1432 |
methDesc.descriptor = m.descriptor.getValue(cf.constant_pool); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1433 |
for (Attribute attr : m.attributes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1434 |
readAttribute(cf, methDesc, attr); |
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 |
addMethod(clazzDesc, methDesc, version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1437 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1438 |
for (Field f : cf.fields) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1439 |
if (!include(f.access_flags.flags)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1440 |
continue; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1441 |
FieldDescription fieldDesc = new FieldDescription(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1442 |
fieldDesc.flags = f.access_flags.flags; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1443 |
fieldDesc.name = f.getName(cf.constant_pool); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1444 |
fieldDesc.descriptor = f.descriptor.getValue(cf.constant_pool); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1445 |
for (Attribute attr : f.attributes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1446 |
readAttribute(cf, fieldDesc, attr); |
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 |
addField(clazzDesc, fieldDesc, version); |
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 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1451 |
|
47703 | 1452 |
private void inspectModuleInfoClassFile(InputStream in, |
1453 |
Map<String, ModuleDescription> modules, |
|
1454 |
String version) throws IOException, ConstantPoolException { |
|
1455 |
ClassFile cf = ClassFile.read(in); |
|
1456 |
||
1457 |
if (!cf.access_flags.is(AccessFlags.ACC_MODULE)) { |
|
1458 |
return ; |
|
1459 |
} |
|
1460 |
||
1461 |
ModuleHeaderDescription headerDesc = new ModuleHeaderDescription(); |
|
1462 |
||
1463 |
headerDesc.versions = version; |
|
1464 |
headerDesc.flags = cf.access_flags.flags; |
|
1465 |
||
1466 |
for (Attribute attr : cf.attributes) { |
|
1467 |
if (!readAttribute(cf, headerDesc, attr)) |
|
1468 |
return ; |
|
1469 |
} |
|
1470 |
||
1471 |
String name = headerDesc.name; |
|
1472 |
||
1473 |
ModuleDescription moduleDesc = modules.get(name); |
|
1474 |
||
1475 |
if (moduleDesc == null) { |
|
1476 |
moduleDesc = new ModuleDescription(); |
|
1477 |
moduleDesc.name = name; |
|
1478 |
modules.put(moduleDesc.name, moduleDesc); |
|
1479 |
} |
|
1480 |
||
1481 |
addModuleHeader(moduleDesc, headerDesc, version); |
|
1482 |
} |
|
1483 |
||
1484 |
private void addModuleHeader(ModuleDescription moduleDesc, |
|
1485 |
ModuleHeaderDescription headerDesc, |
|
1486 |
String version) { |
|
1487 |
//normalize: |
|
1488 |
boolean existed = false; |
|
1489 |
for (ModuleHeaderDescription existing : moduleDesc.header) { |
|
1490 |
if (existing.equals(headerDesc)) { |
|
1491 |
headerDesc = existing; |
|
1492 |
existed = true; |
|
1493 |
} |
|
1494 |
} |
|
1495 |
||
1496 |
headerDesc.versions += version; |
|
1497 |
||
1498 |
if (!existed) { |
|
1499 |
moduleDesc.header.add(headerDesc); |
|
1500 |
} |
|
1501 |
} |
|
1502 |
||
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1503 |
private boolean include(int accessFlags) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1504 |
return (accessFlags & (AccessFlags.ACC_PUBLIC | AccessFlags.ACC_PROTECTED)) != 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1505 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1506 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1507 |
private void addClassHeader(ClassDescription clazzDesc, ClassHeaderDescription headerDesc, String version) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1508 |
//normalize: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1509 |
boolean existed = false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1510 |
for (ClassHeaderDescription existing : clazzDesc.header) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1511 |
if (existing.equals(headerDesc)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1512 |
headerDesc = existing; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1513 |
existed = true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1514 |
} else { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1515 |
//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
|
1516 |
//if so, copy it to the pre-8 version, so save space |
47703 | 1517 |
List<AnnotationDescription> annots = existing.classAnnotations; |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1518 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1519 |
if (annots != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1520 |
for (AnnotationDescription ad : annots) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1521 |
if (PROFILE_ANNOTATION.equals(ad.annotationType)) { |
47703 | 1522 |
existing.classAnnotations = new ArrayList<>(annots); |
1523 |
existing.classAnnotations.remove(ad); |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1524 |
if (existing.equals(headerDesc)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1525 |
headerDesc = existing; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1526 |
existed = true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1527 |
} |
47703 | 1528 |
existing.classAnnotations = annots; |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1529 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1530 |
} |
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 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1533 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1534 |
} |
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 |
headerDesc.versions += version; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1537 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1538 |
if (!existed) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1539 |
clazzDesc.header.add(headerDesc); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1540 |
} |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1543 |
private void addMethod(ClassDescription clazzDesc, MethodDescription methDesc, String version) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1544 |
//normalize: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1545 |
boolean methodExisted = false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1546 |
for (MethodDescription existing : clazzDesc.methods) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1547 |
if (existing.equals(methDesc)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1548 |
methodExisted = true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1549 |
methDesc = existing; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1550 |
break; |
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 |
methDesc.versions += version; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1554 |
if (!methodExisted) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1555 |
clazzDesc.methods.add(methDesc); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1556 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1557 |
} |
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 |
private void addField(ClassDescription clazzDesc, FieldDescription fieldDesc, String version) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1560 |
boolean fieldExisted = false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1561 |
for (FieldDescription existing : clazzDesc.fields) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1562 |
if (existing.equals(fieldDesc)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1563 |
fieldExisted = true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1564 |
fieldDesc = existing; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1565 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1566 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1567 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1568 |
fieldDesc.versions += version; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1569 |
if (!fieldExisted) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1570 |
clazzDesc.fields.add(fieldDesc); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1571 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1572 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1573 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1574 |
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
|
1575 |
String attrName = attr.getName(cf.constant_pool); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1576 |
switch (attrName) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1577 |
case Attribute.AnnotationDefault: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1578 |
assert feature instanceof MethodDescription; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1579 |
element_value defaultValue = ((AnnotationDefault_attribute) attr).default_value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1580 |
((MethodDescription) feature).annotationDefaultValue = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1581 |
convertElementValue(cf.constant_pool, defaultValue); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1582 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1583 |
case "Deprecated": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1584 |
feature.deprecated = true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1585 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1586 |
case "Exceptions": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1587 |
assert feature instanceof MethodDescription; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1588 |
List<String> thrownTypes = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1589 |
Exceptions_attribute exceptionAttr = (Exceptions_attribute) attr; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1590 |
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
|
1591 |
thrownTypes.add(exceptionAttr.getException(i, cf.constant_pool)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1592 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1593 |
((MethodDescription) feature).thrownTypes = thrownTypes; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1594 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1595 |
case Attribute.InnerClasses: |
47703 | 1596 |
if (feature instanceof ModuleHeaderDescription) |
1597 |
break; //XXX |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1598 |
assert feature instanceof ClassHeaderDescription; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1599 |
List<InnerClassInfo> innerClasses = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1600 |
InnerClasses_attribute innerClassesAttr = (InnerClasses_attribute) attr; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1601 |
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
|
1602 |
CONSTANT_Class_info outerClassInfo = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1603 |
innerClassesAttr.classes[i].getOuterClassInfo(cf.constant_pool); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1604 |
InnerClassInfo info = new InnerClassInfo(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1605 |
CONSTANT_Class_info innerClassInfo = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1606 |
innerClassesAttr.classes[i].getInnerClassInfo(cf.constant_pool); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1607 |
info.innerClass = innerClassInfo != null ? innerClassInfo.getName() : null; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1608 |
info.outerClass = outerClassInfo != null ? outerClassInfo.getName() : null; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1609 |
info.innerClassName = innerClassesAttr.classes[i].getInnerName(cf.constant_pool); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1610 |
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
|
1611 |
innerClasses.add(info); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1612 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1613 |
((ClassHeaderDescription) feature).innerClasses = innerClasses; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1614 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1615 |
case "RuntimeInvisibleAnnotations": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1616 |
feature.classAnnotations = annotations2Description(cf.constant_pool, attr); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1617 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1618 |
case "RuntimeVisibleAnnotations": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1619 |
feature.runtimeAnnotations = annotations2Description(cf.constant_pool, attr); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1620 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1621 |
case "Signature": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1622 |
feature.signature = ((Signature_attribute) attr).getSignature(cf.constant_pool); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1623 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1624 |
case "ConstantValue": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1625 |
assert feature instanceof FieldDescription; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1626 |
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
|
1627 |
if (((FieldDescription) feature).descriptor.equals("C")) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1628 |
value = (char) (int) value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1629 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1630 |
((FieldDescription) feature).constantValue = value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1631 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1632 |
case "SourceFile": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1633 |
//ignore, not needed |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1634 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1635 |
case "BootstrapMethods": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1636 |
//ignore, not needed |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1637 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1638 |
case "Code": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1639 |
//ignore, not needed |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1640 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1641 |
case "EnclosingMethod": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1642 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1643 |
case "Synthetic": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1644 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1645 |
case "RuntimeVisibleParameterAnnotations": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1646 |
assert feature instanceof MethodDescription; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1647 |
((MethodDescription) feature).runtimeParameterAnnotations = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1648 |
parameterAnnotations2Description(cf.constant_pool, attr); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1649 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1650 |
case "RuntimeInvisibleParameterAnnotations": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1651 |
assert feature instanceof MethodDescription; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1652 |
((MethodDescription) feature).classParameterAnnotations = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1653 |
parameterAnnotations2Description(cf.constant_pool, attr); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1654 |
break; |
47703 | 1655 |
case Attribute.Module: { |
1656 |
assert feature instanceof ModuleHeaderDescription; |
|
1657 |
ModuleHeaderDescription header = |
|
1658 |
(ModuleHeaderDescription) feature; |
|
1659 |
Module_attribute mod = (Module_attribute) attr; |
|
1660 |
||
1661 |
header.name = cf.constant_pool |
|
1662 |
.getModuleInfo(mod.module_name) |
|
1663 |
.getName(); |
|
1664 |
||
1665 |
header.exports = |
|
1666 |
Arrays.stream(mod.exports) |
|
1667 |
.filter(ee -> ee.exports_to_count == 0) |
|
1668 |
.map(ee -> getPackageName(cf, ee.exports_index)) |
|
1669 |
.collect(Collectors.toList()); |
|
1670 |
header.requires = |
|
1671 |
Arrays.stream(mod.requires) |
|
1672 |
.map(r -> RequiresDescription.create(cf, r)) |
|
1673 |
.collect(Collectors.toList()); |
|
1674 |
header.uses = Arrays.stream(mod.uses_index) |
|
1675 |
.mapToObj(use -> getClassName(cf, use)) |
|
1676 |
.collect(Collectors.toList()); |
|
1677 |
header.provides = |
|
1678 |
Arrays.stream(mod.provides) |
|
1679 |
.map(p -> ProvidesDescription.create(cf, p)) |
|
1680 |
.collect(Collectors.toList()); |
|
1681 |
break; |
|
1682 |
} |
|
1683 |
case Attribute.ModuleTarget: { |
|
1684 |
assert feature instanceof ModuleHeaderDescription; |
|
1685 |
ModuleHeaderDescription header = |
|
1686 |
(ModuleHeaderDescription) feature; |
|
1687 |
ModuleTarget_attribute mod = (ModuleTarget_attribute) attr; |
|
1688 |
if (mod.target_platform_index != 0) { |
|
1689 |
header.moduleTarget = |
|
1690 |
cf.constant_pool |
|
1691 |
.getUTF8Value(mod.target_platform_index); |
|
1692 |
} |
|
1693 |
break; |
|
1694 |
} |
|
1695 |
case Attribute.ModuleResolution: { |
|
1696 |
assert feature instanceof ModuleHeaderDescription; |
|
1697 |
ModuleHeaderDescription header = |
|
1698 |
(ModuleHeaderDescription) feature; |
|
1699 |
ModuleResolution_attribute mod = |
|
1700 |
(ModuleResolution_attribute) attr; |
|
1701 |
header.moduleResolution = mod.resolution_flags; |
|
1702 |
break; |
|
1703 |
} |
|
1704 |
case Attribute.ModulePackages: |
|
1705 |
case Attribute.ModuleHashes: |
|
1706 |
break; |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1707 |
default: |
47703 | 1708 |
throw new IllegalStateException("Unhandled attribute: " + |
1709 |
attrName); |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1710 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1711 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1712 |
return true; |
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 |
|
47703 | 1715 |
private static String getClassName(ClassFile cf, int idx) { |
1716 |
try { |
|
1717 |
return cf.constant_pool.getClassInfo(idx).getName(); |
|
1718 |
} catch (InvalidIndex ex) { |
|
1719 |
throw new IllegalStateException(ex); |
|
1720 |
} catch (ConstantPool.UnexpectedEntry ex) { |
|
1721 |
throw new IllegalStateException(ex); |
|
1722 |
} catch (ConstantPoolException ex) { |
|
1723 |
throw new IllegalStateException(ex); |
|
1724 |
} |
|
1725 |
} |
|
1726 |
||
1727 |
private static String getPackageName(ClassFile cf, int idx) { |
|
1728 |
try { |
|
1729 |
return cf.constant_pool.getPackageInfo(idx).getName(); |
|
1730 |
} catch (InvalidIndex ex) { |
|
1731 |
throw new IllegalStateException(ex); |
|
1732 |
} catch (ConstantPool.UnexpectedEntry ex) { |
|
1733 |
throw new IllegalStateException(ex); |
|
1734 |
} catch (ConstantPoolException ex) { |
|
1735 |
throw new IllegalStateException(ex); |
|
1736 |
} |
|
1737 |
} |
|
1738 |
||
1739 |
private static String getModuleName(ClassFile cf, int idx) { |
|
1740 |
try { |
|
1741 |
return cf.constant_pool.getModuleInfo(idx).getName(); |
|
1742 |
} catch (InvalidIndex ex) { |
|
1743 |
throw new IllegalStateException(ex); |
|
1744 |
} catch (ConstantPool.UnexpectedEntry ex) { |
|
1745 |
throw new IllegalStateException(ex); |
|
1746 |
} catch (ConstantPoolException ex) { |
|
1747 |
throw new IllegalStateException(ex); |
|
1748 |
} |
|
1749 |
} |
|
1750 |
||
1751 |
private static Integer getVersion(ClassFile cf, int idx) { |
|
1752 |
if (idx == 0) |
|
1753 |
return null; |
|
1754 |
try { |
|
1755 |
return ((CONSTANT_Integer_info) cf.constant_pool.get(idx)).value; |
|
1756 |
} catch (InvalidIndex ex) { |
|
1757 |
throw new IllegalStateException(ex); |
|
1758 |
} |
|
1759 |
} |
|
1760 |
||
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1761 |
Object convertConstantValue(CPInfo info, String descriptor) throws ConstantPoolException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1762 |
if (info instanceof CONSTANT_Integer_info) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1763 |
if ("Z".equals(descriptor)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1764 |
return ((CONSTANT_Integer_info) info).value == 1; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1765 |
else |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1766 |
return ((CONSTANT_Integer_info) info).value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1767 |
} else if (info instanceof CONSTANT_Long_info) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1768 |
return ((CONSTANT_Long_info) info).value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1769 |
} else if (info instanceof CONSTANT_Float_info) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1770 |
return ((CONSTANT_Float_info) info).value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1771 |
} else if (info instanceof CONSTANT_Double_info) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1772 |
return ((CONSTANT_Double_info) info).value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1773 |
} else if (info instanceof CONSTANT_String_info) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1774 |
return ((CONSTANT_String_info) info).getString(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1775 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1776 |
throw new IllegalStateException(info.getClass().getName()); |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1779 |
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
|
1780 |
switch (val.tag) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1781 |
case 'Z': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1782 |
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
|
1783 |
case 'B': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1784 |
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
|
1785 |
case 'C': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1786 |
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
|
1787 |
case 'S': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1788 |
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
|
1789 |
case 'I': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1790 |
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
|
1791 |
case 'J': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1792 |
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
|
1793 |
case 'F': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1794 |
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
|
1795 |
case 'D': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1796 |
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
|
1797 |
case 's': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1798 |
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
|
1799 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1800 |
case 'e': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1801 |
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
|
1802 |
cp.getUTF8Value(((Enum_element_value) val).const_name_index)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1803 |
case 'c': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1804 |
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
|
1805 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1806 |
case '@': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1807 |
return annotation2Description(cp, ((Annotation_element_value) val).annotation_value); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1808 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1809 |
case '[': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1810 |
List<Object> values = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1811 |
for (element_value elem : ((Array_element_value) val).values) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1812 |
values.add(convertElementValue(cp, elem)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1813 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1814 |
return values; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1815 |
default: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1816 |
throw new IllegalStateException("Currently unhandled tag: " + val.tag); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1817 |
} |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1820 |
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
|
1821 |
RuntimeAnnotations_attribute annotationsAttr = (RuntimeAnnotations_attribute) attr; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1822 |
List<AnnotationDescription> descs = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1823 |
for (Annotation a : annotationsAttr.annotations) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1824 |
descs.add(annotation2Description(cp, a)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1825 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1826 |
return descs; |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1829 |
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
|
1830 |
RuntimeParameterAnnotations_attribute annotationsAttr = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1831 |
(RuntimeParameterAnnotations_attribute) attr; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1832 |
List<List<AnnotationDescription>> descs = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1833 |
for (Annotation[] attrAnnos : annotationsAttr.parameter_annotations) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1834 |
List<AnnotationDescription> paramDescs = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1835 |
for (Annotation ann : attrAnnos) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1836 |
paramDescs.add(annotation2Description(cp, ann)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1837 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1838 |
descs.add(paramDescs); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1839 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1840 |
return descs; |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1843 |
private AnnotationDescription annotation2Description(ConstantPool cp, Annotation a) throws ConstantPoolException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1844 |
String annotationType = cp.getUTF8Value(a.type_index); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1845 |
Map<String, Object> values = new HashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1846 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1847 |
for (element_value_pair e : a.element_value_pairs) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1848 |
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
|
1849 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1850 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1851 |
return new AnnotationDescription(annotationType, values); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1852 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1853 |
//</editor-fold> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1854 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1855 |
protected boolean includeEffectiveAccess(ClassList classes, ClassDescription clazz) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1856 |
if (!include(clazz.header.get(0).flags)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1857 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1858 |
for (ClassDescription outer : classes.enclosingClasses(clazz)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1859 |
if (!include(outer.header.get(0).flags)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1860 |
return false; |
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 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1863 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1864 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1865 |
boolean include(Set<String> includedClasses, ClassList classes, String clazzName) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1866 |
if (clazzName == null) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1867 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1868 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1869 |
boolean modified = includedClasses.add(clazzName); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1870 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1871 |
for (ClassDescription outer : classes.enclosingClasses(classes.find(clazzName, true))) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1872 |
modified |= includedClasses.add(outer.name); |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1875 |
return modified; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1876 |
} |
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 |
<T extends FeatureDescription> boolean includeOutputType(Iterable<T> features, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1879 |
Function<T, String> feature2Descriptor, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1880 |
Set<String> includedClasses, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1881 |
ClassList classes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1882 |
boolean modified = false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1883 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1884 |
for (T feature : features) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1885 |
CharSequence sig = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1886 |
feature.signature != null ? feature.signature : feature2Descriptor.apply(feature); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1887 |
Matcher m = OUTPUT_TYPE_PATTERN.matcher(sig); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1888 |
while (m.find()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1889 |
modified |= include(includedClasses, classes, m.group(1)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1890 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1891 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1892 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1893 |
return modified; |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1896 |
static final Pattern OUTPUT_TYPE_PATTERN = Pattern.compile("L([^;<]+)(;|<)"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1897 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1898 |
public static class VersionDescription { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1899 |
public final String classes; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1900 |
public final String version; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1901 |
public final String primaryBaseline; |
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 |
public VersionDescription(String classes, String version, String primaryBaseline) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1904 |
this.classes = classes; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1905 |
this.version = version; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1906 |
this.primaryBaseline = "<none>".equals(primaryBaseline) ? null : primaryBaseline; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1907 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1908 |
|
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1911 |
public static class ExcludeIncludeList { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1912 |
public final Set<String> includeList; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1913 |
public final Set<String> excludeList; |
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 |
protected ExcludeIncludeList(Set<String> includeList, Set<String> excludeList) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1916 |
this.includeList = includeList; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1917 |
this.excludeList = excludeList; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1918 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1919 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1920 |
public static ExcludeIncludeList create(String files) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1921 |
Set<String> includeList = new HashSet<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1922 |
Set<String> excludeList = new HashSet<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1923 |
for (String file : files.split(File.pathSeparator)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1924 |
try (Stream<String> lines = Files.lines(Paths.get(file))) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1925 |
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
|
1926 |
.filter(l -> !l.trim().isEmpty()) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1927 |
.forEach(l -> { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1928 |
Set<String> target = l.startsWith("+") ? includeList : excludeList; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1929 |
target.add(l.substring(1)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1930 |
}); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1931 |
} |
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 |
return new ExcludeIncludeList(includeList, excludeList); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1934 |
} |
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 |
public boolean accepts(String className) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1937 |
return matches(includeList, className) && !matches(excludeList, className); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1938 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1939 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1940 |
private static boolean matches(Set<String> list, String className) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1941 |
if (list.contains(className)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1942 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1943 |
String pack = className.substring(0, className.lastIndexOf('/') + 1); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1944 |
return list.contains(pack); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1945 |
} |
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 |
//</editor-fold> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1948 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1949 |
//<editor-fold defaultstate="collapsed" desc="Class Data Structures"> |
47703 | 1950 |
static boolean checkChange(String versions, String version, |
1951 |
String baselineVersion) { |
|
1952 |
return versions.contains(version) ^ |
|
1953 |
(baselineVersion != null && |
|
1954 |
versions.contains(baselineVersion)); |
|
1955 |
} |
|
1956 |
||
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1957 |
static abstract class FeatureDescription { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1958 |
int flags; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1959 |
boolean deprecated; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1960 |
String signature; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1961 |
String versions = ""; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1962 |
List<AnnotationDescription> classAnnotations; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1963 |
List<AnnotationDescription> runtimeAnnotations; |
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 |
protected void writeAttributes(Appendable output) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1966 |
if (flags != 0) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1967 |
output.append(" flags " + Integer.toHexString(flags)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1968 |
if (deprecated) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1969 |
output.append(" deprecated true"); |
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 |
if (signature != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1972 |
output.append(" signature " + quote(signature, false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1973 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1974 |
if (classAnnotations != null && !classAnnotations.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1975 |
output.append(" classAnnotations "); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1976 |
for (AnnotationDescription a : classAnnotations) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1977 |
output.append(quote(a.toString(), false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1978 |
} |
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 |
if (runtimeAnnotations != null && !runtimeAnnotations.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1981 |
output.append(" runtimeAnnotations "); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1982 |
for (AnnotationDescription a : runtimeAnnotations) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1983 |
output.append(quote(a.toString(), false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1984 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1985 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1986 |
} |
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 |
protected boolean shouldIgnore(String baselineVersion, String version) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1989 |
return (!versions.contains(version) && |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1990 |
(baselineVersion == null || !versions.contains(baselineVersion))) || |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1991 |
(baselineVersion != null && |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1992 |
versions.contains(baselineVersion) && versions.contains(version)); |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1995 |
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
|
1996 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1997 |
protected void readAttributes(LineBasedReader reader) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1998 |
String inFlags = reader.attributes.get("flags"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1999 |
if (inFlags != null && !inFlags.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2000 |
flags = Integer.parseInt(inFlags, 16); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2001 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2002 |
String inDeprecated = reader.attributes.get("deprecated"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2003 |
if ("true".equals(inDeprecated)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2004 |
deprecated = 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 |
signature = reader.attributes.get("signature"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2007 |
String inClassAnnotations = reader.attributes.get("classAnnotations"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2008 |
if (inClassAnnotations != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2009 |
classAnnotations = parseAnnotations(unquote(inClassAnnotations), new int[1]); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2010 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2011 |
String inRuntimeAnnotations = reader.attributes.get("runtimeAnnotations"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2012 |
if (inRuntimeAnnotations != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2013 |
runtimeAnnotations = parseAnnotations(unquote(inRuntimeAnnotations), new int[1]); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2014 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2015 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2016 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2017 |
public abstract boolean read(LineBasedReader reader) throws IOException; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2018 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2019 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2020 |
public int hashCode() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2021 |
int hash = 3; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2022 |
hash = 89 * hash + this.flags; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2023 |
hash = 89 * hash + (this.deprecated ? 1 : 0); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2024 |
hash = 89 * hash + Objects.hashCode(this.signature); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2025 |
hash = 89 * hash + listHashCode(this.classAnnotations); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2026 |
hash = 89 * hash + listHashCode(this.runtimeAnnotations); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2027 |
return hash; |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2030 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2031 |
public boolean equals(Object obj) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2032 |
if (obj == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2033 |
return false; |
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 |
if (getClass() != obj.getClass()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2036 |
return false; |
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 |
final FeatureDescription other = (FeatureDescription) obj; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2039 |
if (this.flags != other.flags) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2040 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2041 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2042 |
if (this.deprecated != other.deprecated) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2043 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2044 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2045 |
if (!Objects.equals(this.signature, other.signature)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2046 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2047 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2048 |
if (!listEquals(this.classAnnotations, other.classAnnotations)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2049 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2050 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2051 |
if (!listEquals(this.runtimeAnnotations, other.runtimeAnnotations)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2052 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2053 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2054 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2055 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2056 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2057 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2058 |
|
47703 | 2059 |
public static class ModuleDescription { |
2060 |
String name; |
|
2061 |
List<ModuleHeaderDescription> header = new ArrayList<>(); |
|
2062 |
||
2063 |
public void write(Appendable output, String baselineVersion, |
|
2064 |
String version) throws IOException { |
|
2065 |
boolean inBaseline = false; |
|
2066 |
boolean inVersion = false; |
|
2067 |
for (ModuleHeaderDescription mhd : header) { |
|
2068 |
if (baselineVersion != null && |
|
2069 |
mhd.versions.contains(baselineVersion)) { |
|
2070 |
inBaseline = true; |
|
2071 |
} |
|
2072 |
if (mhd.versions.contains(version)) { |
|
2073 |
inVersion = true; |
|
2074 |
} |
|
2075 |
} |
|
2076 |
if (!inVersion && !inBaseline) |
|
2077 |
return ; |
|
2078 |
if (!inVersion) { |
|
2079 |
output.append("-module name " + name + "\n\n"); |
|
2080 |
return; |
|
2081 |
} |
|
2082 |
boolean hasChange = hasChange(header, version, baselineVersion); |
|
2083 |
if (!hasChange) |
|
2084 |
return; |
|
2085 |
||
2086 |
output.append("module name " + name + "\n"); |
|
2087 |
for (ModuleHeaderDescription header : header) { |
|
2088 |
header.write(output, baselineVersion, version); |
|
2089 |
} |
|
2090 |
output.append("\n"); |
|
2091 |
} |
|
2092 |
||
2093 |
boolean hasChange(List<? extends FeatureDescription> hasChange, |
|
2094 |
String version, String baseline) { |
|
2095 |
return hasChange.stream() |
|
2096 |
.map(fd -> fd.versions) |
|
2097 |
.anyMatch(versions -> checkChange(versions, |
|
2098 |
version, |
|
2099 |
baseline)); |
|
2100 |
} |
|
2101 |
||
2102 |
public void read(LineBasedReader reader, String baselineVersion, |
|
2103 |
String version) throws IOException { |
|
2104 |
if (!"module".equals(reader.lineKey)) |
|
2105 |
return ; |
|
2106 |
||
2107 |
name = reader.attributes.get("name"); |
|
2108 |
||
2109 |
reader.moveNext(); |
|
2110 |
||
2111 |
OUTER: while (reader.hasNext()) { |
|
2112 |
switch (reader.lineKey) { |
|
2113 |
case "header": |
|
2114 |
removeVersion(header, h -> true, version); |
|
2115 |
ModuleHeaderDescription mhd = |
|
2116 |
new ModuleHeaderDescription(); |
|
2117 |
mhd.read(reader); |
|
2118 |
mhd.versions = version; |
|
2119 |
header.add(mhd); |
|
2120 |
break; |
|
2121 |
case "class": |
|
2122 |
case "-class": |
|
2123 |
case "module": |
|
2124 |
case "-module": |
|
2125 |
break OUTER; |
|
2126 |
default: |
|
2127 |
throw new IllegalStateException(reader.lineKey); |
|
2128 |
} |
|
2129 |
} |
|
2130 |
} |
|
2131 |
} |
|
2132 |
||
2133 |
static class ModuleHeaderDescription extends HeaderDescription { |
|
2134 |
String name; |
|
2135 |
List<String> exports = new ArrayList<>(); |
|
2136 |
List<String> opens = new ArrayList<>(); |
|
2137 |
List<RequiresDescription> requires = new ArrayList<>(); |
|
2138 |
List<String> uses = new ArrayList<>(); |
|
2139 |
List<ProvidesDescription> provides = new ArrayList<>(); |
|
2140 |
Integer moduleResolution; |
|
2141 |
String moduleTarget; |
|
2142 |
||
2143 |
@Override |
|
2144 |
public int hashCode() { |
|
2145 |
int hash = super.hashCode(); |
|
2146 |
hash = 83 * hash + Objects.hashCode(this.name); |
|
2147 |
hash = 83 * hash + Objects.hashCode(this.exports); |
|
2148 |
hash = 83 * hash + Objects.hashCode(this.opens); |
|
2149 |
hash = 83 * hash + Objects.hashCode(this.requires); |
|
2150 |
hash = 83 * hash + Objects.hashCode(this.uses); |
|
2151 |
hash = 83 * hash + Objects.hashCode(this.provides); |
|
2152 |
hash = 83 * hash + Objects.hashCode(this.moduleResolution); |
|
2153 |
hash = 83 * hash + Objects.hashCode(this.moduleTarget); |
|
2154 |
return hash; |
|
2155 |
} |
|
2156 |
||
2157 |
@Override |
|
2158 |
public boolean equals(Object obj) { |
|
2159 |
if (this == obj) { |
|
2160 |
return true; |
|
2161 |
} |
|
2162 |
if (!super.equals(obj)) { |
|
2163 |
return false; |
|
2164 |
} |
|
2165 |
final ModuleHeaderDescription other = |
|
2166 |
(ModuleHeaderDescription) obj; |
|
2167 |
if (!Objects.equals(this.name, other.name)) { |
|
2168 |
return false; |
|
2169 |
} |
|
2170 |
if (!listEquals(this.exports, other.exports)) { |
|
2171 |
return false; |
|
2172 |
} |
|
2173 |
if (!listEquals(this.opens, other.opens)) { |
|
2174 |
return false; |
|
2175 |
} |
|
2176 |
if (!listEquals(this.requires, other.requires)) { |
|
2177 |
return false; |
|
2178 |
} |
|
2179 |
if (!listEquals(this.uses, other.uses)) { |
|
2180 |
return false; |
|
2181 |
} |
|
2182 |
if (!listEquals(this.provides, other.provides)) { |
|
2183 |
return false; |
|
2184 |
} |
|
2185 |
if (!Objects.equals(this.moduleTarget, other.moduleTarget)) { |
|
2186 |
return false; |
|
2187 |
} |
|
2188 |
if (!Objects.equals(this.moduleResolution, |
|
2189 |
other.moduleResolution)) { |
|
2190 |
return false; |
|
2191 |
} |
|
2192 |
return true; |
|
2193 |
} |
|
2194 |
||
2195 |
@Override |
|
2196 |
public void write(Appendable output, String baselineVersion, |
|
2197 |
String version) throws IOException { |
|
2198 |
if (!versions.contains(version) || |
|
2199 |
(baselineVersion != null && versions.contains(baselineVersion) |
|
2200 |
&& versions.contains(version))) |
|
2201 |
return ; |
|
2202 |
output.append("header"); |
|
2203 |
if (exports != null && !exports.isEmpty()) |
|
2204 |
output.append(" exports " + serializeList(exports)); |
|
2205 |
if (opens != null && !opens.isEmpty()) |
|
2206 |
output.append(" opens " + serializeList(opens)); |
|
2207 |
if (requires != null && !requires.isEmpty()) { |
|
2208 |
List<String> requiresList = |
|
2209 |
requires.stream() |
|
2210 |
.map(req -> req.serialize()) |
|
2211 |
.collect(Collectors.toList()); |
|
2212 |
output.append(" requires " + serializeList(requiresList)); |
|
2213 |
} |
|
2214 |
if (uses != null && !uses.isEmpty()) |
|
2215 |
output.append(" uses " + serializeList(uses)); |
|
2216 |
if (provides != null && !provides.isEmpty()) { |
|
2217 |
List<String> providesList = |
|
2218 |
provides.stream() |
|
2219 |
.map(p -> p.serialize()) |
|
2220 |
.collect(Collectors.toList()); |
|
2221 |
output.append(" provides " + serializeList(providesList)); |
|
2222 |
} |
|
2223 |
if (moduleTarget != null) |
|
2224 |
output.append(" target " + quote(moduleTarget, true)); |
|
2225 |
if (moduleResolution != null) |
|
2226 |
output.append(" resolution " + |
|
2227 |
quote(Integer.toHexString(moduleResolution), |
|
2228 |
true)); |
|
2229 |
writeAttributes(output); |
|
2230 |
output.append("\n"); |
|
2231 |
writeInnerClasses(output, baselineVersion, version); |
|
2232 |
} |
|
2233 |
||
2234 |
private static Map<String, String> splitAttributes(String data) { |
|
2235 |
String[] parts = data.split(" "); |
|
2236 |
||
2237 |
Map<String, String> attributes = new HashMap<>(); |
|
2238 |
||
2239 |
for (int i = 0; i < parts.length; i += 2) { |
|
2240 |
attributes.put(parts[i], unquote(parts[i + 1])); |
|
2241 |
} |
|
2242 |
||
2243 |
return attributes; |
|
2244 |
} |
|
2245 |
||
2246 |
@Override |
|
2247 |
public boolean read(LineBasedReader reader) throws IOException { |
|
2248 |
if (!"header".equals(reader.lineKey)) |
|
2249 |
return false; |
|
2250 |
||
2251 |
exports = deserializeList(reader.attributes.get("exports")); |
|
2252 |
opens = deserializeList(reader.attributes.get("opens")); |
|
2253 |
List<String> requiresList = |
|
2254 |
deserializeList(reader.attributes.get("requires")); |
|
2255 |
requires = requiresList.stream() |
|
2256 |
.map(RequiresDescription::deserialize) |
|
2257 |
.collect(Collectors.toList()); |
|
2258 |
uses = deserializeList(reader.attributes.get("uses")); |
|
2259 |
List<String> providesList = |
|
2260 |
deserializeList(reader.attributes.get("provides"), false); |
|
2261 |
provides = providesList.stream() |
|
2262 |
.map(ProvidesDescription::deserialize) |
|
2263 |
.collect(Collectors.toList()); |
|
2264 |
||
2265 |
moduleTarget = reader.attributes.get("target"); |
|
2266 |
||
2267 |
if (reader.attributes.containsKey("resolution")) { |
|
2268 |
final String resolutionFlags = |
|
2269 |
reader.attributes.get("resolution"); |
|
2270 |
moduleResolution = Integer.parseInt(resolutionFlags, 16); |
|
2271 |
} |
|
2272 |
||
2273 |
readAttributes(reader); |
|
2274 |
reader.moveNext(); |
|
2275 |
readInnerClasses(reader); |
|
2276 |
||
2277 |
return true; |
|
2278 |
} |
|
2279 |
||
2280 |
static class RequiresDescription { |
|
2281 |
final String moduleName; |
|
2282 |
final int flags; |
|
2283 |
final Integer version; |
|
2284 |
||
2285 |
public RequiresDescription(String moduleName, int flags, |
|
2286 |
Integer version) { |
|
2287 |
this.moduleName = moduleName; |
|
2288 |
this.flags = flags; |
|
2289 |
this.version = version; |
|
2290 |
} |
|
2291 |
||
2292 |
public String serialize() { |
|
2293 |
String versionKeyValue = version != null |
|
2294 |
? " version " + quote(String.valueOf(version), true) |
|
2295 |
: ""; |
|
2296 |
return "name " + quote(moduleName, true) + |
|
2297 |
" flags " + quote(Integer.toHexString(flags), true) + |
|
2298 |
versionKeyValue; |
|
2299 |
} |
|
2300 |
||
2301 |
public static RequiresDescription deserialize(String data) { |
|
2302 |
Map<String, String> attributes = splitAttributes(data); |
|
2303 |
||
2304 |
Integer ver = attributes.containsKey("version") |
|
2305 |
? Integer.parseInt(attributes.get("version")) |
|
2306 |
: null; |
|
2307 |
int flags = Integer.parseInt(attributes.get("flags"), 16); |
|
2308 |
return new RequiresDescription(attributes.get("name"), |
|
2309 |
flags, |
|
2310 |
ver); |
|
2311 |
} |
|
2312 |
||
2313 |
public static RequiresDescription create(ClassFile cf, |
|
2314 |
RequiresEntry req) { |
|
2315 |
String mod = getModuleName(cf, req.requires_index); |
|
2316 |
Integer ver = getVersion(cf, req.requires_version_index); |
|
2317 |
return new RequiresDescription(mod, |
|
2318 |
req.requires_flags, |
|
2319 |
ver); |
|
2320 |
} |
|
2321 |
} |
|
2322 |
||
2323 |
static class ProvidesDescription { |
|
2324 |
final String interfaceName; |
|
2325 |
final List<String> implNames; |
|
2326 |
||
2327 |
public ProvidesDescription(String interfaceName, |
|
2328 |
List<String> implNames) { |
|
2329 |
this.interfaceName = interfaceName; |
|
2330 |
this.implNames = implNames; |
|
2331 |
} |
|
2332 |
||
2333 |
public String serialize() { |
|
2334 |
return "interface " + quote(interfaceName, true) + |
|
2335 |
" impls " + quote(serializeList(implNames), true, true); |
|
2336 |
} |
|
2337 |
||
2338 |
public static ProvidesDescription deserialize(String data) { |
|
2339 |
Map<String, String> attributes = splitAttributes(data); |
|
2340 |
List<String> implsList = |
|
2341 |
deserializeList(attributes.get("impls"), |
|
2342 |
false); |
|
2343 |
return new ProvidesDescription(attributes.get("interface"), |
|
2344 |
implsList); |
|
2345 |
} |
|
2346 |
||
2347 |
public static ProvidesDescription create(ClassFile cf, |
|
2348 |
ProvidesEntry prov) { |
|
2349 |
String api = getClassName(cf, prov.provides_index); |
|
2350 |
List<String> impls = |
|
2351 |
Arrays.stream(prov.with_index) |
|
2352 |
.mapToObj(wi -> getClassName(cf, wi)) |
|
2353 |
.collect(Collectors.toList()); |
|
2354 |
return new ProvidesDescription(api, impls); |
|
2355 |
} |
|
2356 |
} |
|
2357 |
} |
|
2358 |
||
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2359 |
public static class ClassDescription { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2360 |
String name; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2361 |
List<ClassHeaderDescription> header = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2362 |
List<MethodDescription> methods = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2363 |
List<FieldDescription> fields = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2364 |
|
47703 | 2365 |
public void write(Appendable output, String baselineVersion, |
2366 |
String version) throws IOException { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2367 |
boolean inBaseline = false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2368 |
boolean inVersion = false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2369 |
for (ClassHeaderDescription chd : header) { |
47703 | 2370 |
if (baselineVersion != null && |
2371 |
chd.versions.contains(baselineVersion)) { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2372 |
inBaseline = true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2373 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2374 |
if (chd.versions.contains(version)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2375 |
inVersion = true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2376 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2377 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2378 |
if (!inVersion && !inBaseline) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2379 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2380 |
if (!inVersion) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2381 |
output.append("-class name " + name + "\n\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2382 |
return; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2383 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2384 |
boolean hasChange = hasChange(header, version, baselineVersion) || |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2385 |
hasChange(fields, version, baselineVersion) || |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2386 |
hasChange(methods, version, baselineVersion); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2387 |
if (!hasChange) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2388 |
return; |
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 |
output.append("class name " + name + "\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2391 |
for (ClassHeaderDescription header : header) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2392 |
header.write(output, baselineVersion, version); |
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 |
for (FieldDescription field : fields) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2395 |
field.write(output, baselineVersion, version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2396 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2397 |
for (MethodDescription method : methods) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2398 |
method.write(output, baselineVersion, version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2399 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2400 |
output.append("\n"); |
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 |
|
47703 | 2403 |
boolean hasChange(List<? extends FeatureDescription> hasChange, |
2404 |
String version, |
|
2405 |
String baseline) { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2406 |
return hasChange.stream() |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2407 |
.map(fd -> fd.versions) |
47703 | 2408 |
.anyMatch(versions -> checkChange(versions, |
2409 |
version, |
|
2410 |
baseline)); |
|
31506
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 |
|
47703 | 2413 |
public void read(LineBasedReader reader, String baselineVersion, |
2414 |
String version) throws IOException { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2415 |
if (!"class".equals(reader.lineKey)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2416 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2417 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2418 |
name = reader.attributes.get("name"); |
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 |
reader.moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2421 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2422 |
OUTER: while (reader.hasNext()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2423 |
switch (reader.lineKey) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2424 |
case "header": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2425 |
removeVersion(header, h -> true, version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2426 |
ClassHeaderDescription chd = new ClassHeaderDescription(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2427 |
chd.read(reader); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2428 |
chd.versions = version; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2429 |
header.add(chd); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2430 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2431 |
case "field": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2432 |
FieldDescription field = new FieldDescription(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2433 |
field.read(reader); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2434 |
field.versions += version; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2435 |
fields.add(field); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2436 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2437 |
case "-field": { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2438 |
removeVersion(fields, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2439 |
f -> Objects.equals(f.name, reader.attributes.get("name")) && |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2440 |
Objects.equals(f.descriptor, reader.attributes.get("descriptor")), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2441 |
version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2442 |
reader.moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2443 |
break; |
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 |
case "method": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2446 |
MethodDescription method = new MethodDescription(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2447 |
method.read(reader); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2448 |
method.versions += version; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2449 |
methods.add(method); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2450 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2451 |
case "-method": { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2452 |
removeVersion(methods, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2453 |
m -> Objects.equals(m.name, reader.attributes.get("name")) && |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2454 |
Objects.equals(m.descriptor, reader.attributes.get("descriptor")), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2455 |
version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2456 |
reader.moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2457 |
break; |
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 |
case "class": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2460 |
case "-class": |
47703 | 2461 |
case "module": |
2462 |
case "-module": |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2463 |
break OUTER; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2464 |
default: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2465 |
throw new IllegalStateException(reader.lineKey); |
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 |
} |
47703 | 2469 |
|
2470 |
public String packge() { |
|
2471 |
String pack; |
|
2472 |
int lastSlash = name.lastIndexOf('/'); |
|
2473 |
if (lastSlash != (-1)) { |
|
2474 |
pack = name.substring(0, lastSlash).replace('/', '.'); |
|
2475 |
} else { |
|
2476 |
pack = ""; |
|
2477 |
} |
|
2478 |
||
2479 |
return pack; |
|
2480 |
} |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2481 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2482 |
|
47703 | 2483 |
static class ClassHeaderDescription extends HeaderDescription { |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2484 |
String extendsAttr; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2485 |
List<String> implementsAttr; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2486 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2487 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2488 |
public int hashCode() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2489 |
int hash = super.hashCode(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2490 |
hash = 17 * hash + Objects.hashCode(this.extendsAttr); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2491 |
hash = 17 * hash + Objects.hashCode(this.implementsAttr); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2492 |
return hash; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2493 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2494 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2495 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2496 |
public boolean equals(Object obj) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2497 |
if (obj == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2498 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2499 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2500 |
if (!super.equals(obj)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2501 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2502 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2503 |
final ClassHeaderDescription other = (ClassHeaderDescription) obj; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2504 |
if (!Objects.equals(this.extendsAttr, other.extendsAttr)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2505 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2506 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2507 |
if (!Objects.equals(this.implementsAttr, other.implementsAttr)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2508 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2509 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2510 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2511 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2512 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2513 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2514 |
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
|
2515 |
if (!versions.contains(version) || |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2516 |
(baselineVersion != null && versions.contains(baselineVersion) && versions.contains(version))) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2517 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2518 |
output.append("header"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2519 |
if (extendsAttr != null) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2520 |
output.append(" extends " + extendsAttr); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2521 |
if (implementsAttr != null && !implementsAttr.isEmpty()) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2522 |
output.append(" implements " + serializeList(implementsAttr)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2523 |
writeAttributes(output); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2524 |
output.append("\n"); |
47703 | 2525 |
writeInnerClasses(output, baselineVersion, version); |
2526 |
} |
|
2527 |
||
2528 |
@Override |
|
2529 |
public boolean read(LineBasedReader reader) throws IOException { |
|
2530 |
if (!"header".equals(reader.lineKey)) |
|
2531 |
return false; |
|
2532 |
||
2533 |
extendsAttr = reader.attributes.get("extends"); |
|
2534 |
String elementsList = reader.attributes.get("implements"); |
|
2535 |
implementsAttr = deserializeList(elementsList); |
|
2536 |
||
2537 |
readAttributes(reader); |
|
2538 |
reader.moveNext(); |
|
2539 |
readInnerClasses(reader); |
|
2540 |
||
2541 |
return true; |
|
2542 |
} |
|
2543 |
||
2544 |
} |
|
2545 |
||
2546 |
static abstract class HeaderDescription extends FeatureDescription { |
|
2547 |
List<InnerClassInfo> innerClasses; |
|
2548 |
||
2549 |
@Override |
|
2550 |
public int hashCode() { |
|
2551 |
int hash = super.hashCode(); |
|
2552 |
hash = 19 * hash + Objects.hashCode(this.innerClasses); |
|
2553 |
return hash; |
|
2554 |
} |
|
2555 |
||
2556 |
@Override |
|
2557 |
public boolean equals(Object obj) { |
|
2558 |
if (obj == null) { |
|
2559 |
return false; |
|
2560 |
} |
|
2561 |
if (!super.equals(obj)) { |
|
2562 |
return false; |
|
2563 |
} |
|
2564 |
final HeaderDescription other = (HeaderDescription) obj; |
|
2565 |
if (!listEquals(this.innerClasses, other.innerClasses)) { |
|
2566 |
return false; |
|
2567 |
} |
|
2568 |
return true; |
|
2569 |
} |
|
2570 |
||
2571 |
protected void writeInnerClasses(Appendable output, |
|
2572 |
String baselineVersion, |
|
2573 |
String version) throws IOException { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2574 |
if (innerClasses != null && !innerClasses.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2575 |
for (InnerClassInfo ici : innerClasses) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2576 |
output.append("innerclass"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2577 |
output.append(" innerClass " + ici.innerClass); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2578 |
output.append(" outerClass " + ici.outerClass); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2579 |
output.append(" innerClassName " + ici.innerClassName); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2580 |
output.append(" flags " + Integer.toHexString(ici.innerClassFlags)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2581 |
output.append("\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2582 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2583 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2584 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2585 |
|
47703 | 2586 |
protected void readInnerClasses(LineBasedReader reader) throws IOException { |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2587 |
innerClasses = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2588 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2589 |
while ("innerclass".equals(reader.lineKey)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2590 |
InnerClassInfo info = new InnerClassInfo(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2591 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2592 |
info.innerClass = reader.attributes.get("innerClass"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2593 |
info.outerClass = reader.attributes.get("outerClass"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2594 |
info.innerClassName = reader.attributes.get("innerClassName"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2595 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2596 |
String inFlags = reader.attributes.get("flags"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2597 |
if (inFlags != null && !inFlags.isEmpty()) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2598 |
info.innerClassFlags = Integer.parseInt(inFlags, 16); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2599 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2600 |
innerClasses.add(info); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2601 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2602 |
reader.moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2603 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2604 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2605 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2606 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2607 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2608 |
static class MethodDescription extends FeatureDescription { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2609 |
String name; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2610 |
String descriptor; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2611 |
List<String> thrownTypes; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2612 |
Object annotationDefaultValue; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2613 |
List<List<AnnotationDescription>> classParameterAnnotations; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2614 |
List<List<AnnotationDescription>> runtimeParameterAnnotations; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2615 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2616 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2617 |
public int hashCode() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2618 |
int hash = super.hashCode(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2619 |
hash = 59 * hash + Objects.hashCode(this.name); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2620 |
hash = 59 * hash + Objects.hashCode(this.descriptor); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2621 |
hash = 59 * hash + Objects.hashCode(this.thrownTypes); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2622 |
hash = 59 * hash + Objects.hashCode(this.annotationDefaultValue); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2623 |
return hash; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2624 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2625 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2626 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2627 |
public boolean equals(Object obj) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2628 |
if (obj == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2629 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2630 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2631 |
if (!super.equals(obj)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2632 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2633 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2634 |
final MethodDescription other = (MethodDescription) obj; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2635 |
if (!Objects.equals(this.name, other.name)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2636 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2637 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2638 |
if (!Objects.equals(this.descriptor, other.descriptor)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2639 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2640 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2641 |
if (!Objects.equals(this.thrownTypes, other.thrownTypes)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2642 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2643 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2644 |
if (!Objects.equals(this.annotationDefaultValue, other.annotationDefaultValue)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2645 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2646 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2647 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2648 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2649 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2650 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2651 |
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
|
2652 |
if (shouldIgnore(baselineVersion, version)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2653 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2654 |
if (!versions.contains(version)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2655 |
output.append("-method"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2656 |
output.append(" name " + quote(name, false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2657 |
output.append(" descriptor " + quote(descriptor, false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2658 |
output.append("\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2659 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2660 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2661 |
output.append("method"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2662 |
output.append(" name " + quote(name, false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2663 |
output.append(" descriptor " + quote(descriptor, false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2664 |
if (thrownTypes != null) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2665 |
output.append(" thrownTypes " + serializeList(thrownTypes)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2666 |
if (annotationDefaultValue != null) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2667 |
output.append(" annotationDefaultValue " + quote(AnnotationDescription.dumpAnnotationValue(annotationDefaultValue), false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2668 |
writeAttributes(output); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2669 |
if (classParameterAnnotations != null && !classParameterAnnotations.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2670 |
output.append(" classParameterAnnotations "); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2671 |
for (List<AnnotationDescription> pa : classParameterAnnotations) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2672 |
for (AnnotationDescription a : pa) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2673 |
output.append(quote(a.toString(), false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2674 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2675 |
output.append(";"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2676 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2677 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2678 |
if (runtimeParameterAnnotations != null && !runtimeParameterAnnotations.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2679 |
output.append(" runtimeParameterAnnotations "); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2680 |
for (List<AnnotationDescription> pa : runtimeParameterAnnotations) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2681 |
for (AnnotationDescription a : pa) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2682 |
output.append(quote(a.toString(), false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2683 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2684 |
output.append(";"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2685 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2686 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2687 |
output.append("\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2688 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2689 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2690 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2691 |
public boolean read(LineBasedReader reader) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2692 |
if (!"method".equals(reader.lineKey)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2693 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2694 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2695 |
name = reader.attributes.get("name"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2696 |
descriptor = reader.attributes.get("descriptor"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2697 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2698 |
thrownTypes = deserializeList(reader.attributes.get("thrownTypes")); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2699 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2700 |
String inAnnotationDefaultValue = reader.attributes.get("annotationDefaultValue"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2701 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2702 |
if (inAnnotationDefaultValue != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2703 |
annotationDefaultValue = parseAnnotationValue(inAnnotationDefaultValue, new int[1]); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2704 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2705 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2706 |
readAttributes(reader); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2707 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2708 |
String inClassParamAnnotations = reader.attributes.get("classParameterAnnotations"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2709 |
if (inClassParamAnnotations != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2710 |
List<List<AnnotationDescription>> annos = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2711 |
int[] pointer = new int[1]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2712 |
do { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2713 |
annos.add(parseAnnotations(inClassParamAnnotations, pointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2714 |
assert pointer[0] == inClassParamAnnotations.length() || inClassParamAnnotations.charAt(pointer[0]) == ';'; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2715 |
} while (++pointer[0] < inClassParamAnnotations.length()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2716 |
classParameterAnnotations = annos; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2717 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2718 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2719 |
String inRuntimeParamAnnotations = reader.attributes.get("runtimeParameterAnnotations"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2720 |
if (inRuntimeParamAnnotations != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2721 |
List<List<AnnotationDescription>> annos = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2722 |
int[] pointer = new int[1]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2723 |
do { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2724 |
annos.add(parseAnnotations(inRuntimeParamAnnotations, pointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2725 |
assert pointer[0] == inRuntimeParamAnnotations.length() || inRuntimeParamAnnotations.charAt(pointer[0]) == ';'; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2726 |
} while (++pointer[0] < inRuntimeParamAnnotations.length()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2727 |
runtimeParameterAnnotations = annos; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2728 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2729 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2730 |
reader.moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2731 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2732 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2733 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2734 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2735 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2736 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2737 |
static class FieldDescription extends FeatureDescription { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2738 |
String name; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2739 |
String descriptor; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2740 |
Object constantValue; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2741 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2742 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2743 |
public int hashCode() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2744 |
int hash = super.hashCode(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2745 |
hash = 59 * hash + Objects.hashCode(this.name); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2746 |
hash = 59 * hash + Objects.hashCode(this.descriptor); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2747 |
hash = 59 * hash + Objects.hashCode(this.constantValue); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2748 |
return hash; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2749 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2750 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2751 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2752 |
public boolean equals(Object obj) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2753 |
if (obj == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2754 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2755 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2756 |
if (!super.equals(obj)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2757 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2758 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2759 |
final FieldDescription other = (FieldDescription) obj; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2760 |
if (!Objects.equals(this.name, other.name)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2761 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2762 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2763 |
if (!Objects.equals(this.descriptor, other.descriptor)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2764 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2765 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2766 |
if (!Objects.equals(this.constantValue, other.constantValue)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2767 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2768 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2769 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2770 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2771 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2772 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2773 |
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
|
2774 |
if (shouldIgnore(baselineVersion, version)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2775 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2776 |
if (!versions.contains(version)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2777 |
output.append("-field"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2778 |
output.append(" name " + quote(name, false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2779 |
output.append(" descriptor " + quote(descriptor, false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2780 |
output.append("\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2781 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2782 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2783 |
output.append("field"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2784 |
output.append(" name " + name); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2785 |
output.append(" descriptor " + descriptor); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2786 |
if (constantValue != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2787 |
output.append(" constantValue " + quote(constantValue.toString(), false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2788 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2789 |
writeAttributes(output); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2790 |
output.append("\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2791 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2792 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2793 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2794 |
public boolean read(LineBasedReader reader) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2795 |
if (!"field".equals(reader.lineKey)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2796 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2797 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2798 |
name = reader.attributes.get("name"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2799 |
descriptor = reader.attributes.get("descriptor"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2800 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2801 |
String inConstantValue = reader.attributes.get("constantValue"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2802 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2803 |
if (inConstantValue != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2804 |
switch (descriptor) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2805 |
case "Z": constantValue = "true".equals(inConstantValue); break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2806 |
case "B": constantValue = Byte.parseByte(inConstantValue); break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2807 |
case "C": constantValue = inConstantValue.charAt(0); break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2808 |
case "S": constantValue = Short.parseShort(inConstantValue); break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2809 |
case "I": constantValue = Integer.parseInt(inConstantValue); break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2810 |
case "J": constantValue = Long.parseLong(inConstantValue); break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2811 |
case "F": constantValue = Float.parseFloat(inConstantValue); break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2812 |
case "D": constantValue = Double.parseDouble(inConstantValue); break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2813 |
case "Ljava/lang/String;": constantValue = inConstantValue; break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2814 |
default: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2815 |
throw new IllegalStateException("Unrecognized field type: " + descriptor); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2816 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2817 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2818 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2819 |
readAttributes(reader); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2820 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2821 |
reader.moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2822 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2823 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2824 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2825 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2826 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2827 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2828 |
static final class AnnotationDescription { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2829 |
String annotationType; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2830 |
Map<String, Object> values; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2831 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2832 |
public AnnotationDescription(String annotationType, Map<String, Object> values) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2833 |
this.annotationType = annotationType; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2834 |
this.values = values; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2835 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2836 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2837 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2838 |
public int hashCode() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2839 |
int hash = 7; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2840 |
hash = 47 * hash + Objects.hashCode(this.annotationType); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2841 |
hash = 47 * hash + Objects.hashCode(this.values); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2842 |
return hash; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2843 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2844 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2845 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2846 |
public boolean equals(Object obj) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2847 |
if (obj == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2848 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2849 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2850 |
if (getClass() != obj.getClass()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2851 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2852 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2853 |
final AnnotationDescription other = (AnnotationDescription) obj; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2854 |
if (!Objects.equals(this.annotationType, other.annotationType)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2855 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2856 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2857 |
if (!Objects.equals(this.values, other.values)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2858 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2859 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2860 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2861 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2862 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2863 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2864 |
public String toString() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2865 |
StringBuilder result = new StringBuilder(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2866 |
result.append("@" + annotationType); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2867 |
if (!values.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2868 |
result.append("("); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2869 |
boolean first = true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2870 |
for (Entry<String, Object> e : values.entrySet()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2871 |
if (!first) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2872 |
result.append(","); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2873 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2874 |
first = false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2875 |
result.append(e.getKey()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2876 |
result.append("="); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2877 |
result.append(dumpAnnotationValue(e.getValue())); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2878 |
result.append(""); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2879 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2880 |
result.append(")"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2881 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2882 |
return result.toString(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2883 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2884 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2885 |
private static String dumpAnnotationValue(Object value) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2886 |
if (value instanceof List) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2887 |
StringBuilder result = new StringBuilder(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2888 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2889 |
result.append("{"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2890 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2891 |
for (Object element : ((List) value)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2892 |
result.append(dumpAnnotationValue(element)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2893 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2894 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2895 |
result.append("}"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2896 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2897 |
return result.toString(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2898 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2899 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2900 |
if (value instanceof String) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2901 |
return "\"" + quote((String) value, true) + "\""; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2902 |
} else if (value instanceof Boolean) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2903 |
return "Z" + value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2904 |
} else if (value instanceof Byte) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2905 |
return "B" + value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2906 |
} if (value instanceof Character) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2907 |
return "C" + value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2908 |
} if (value instanceof Short) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2909 |
return "S" + value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2910 |
} if (value instanceof Integer) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2911 |
return "I" + value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2912 |
} if (value instanceof Long) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2913 |
return "J" + value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2914 |
} if (value instanceof Float) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2915 |
return "F" + value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2916 |
} if (value instanceof Double) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2917 |
return "D" + value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2918 |
} else { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2919 |
return value.toString(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2920 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2921 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2922 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2923 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2924 |
static final class EnumConstant { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2925 |
String type; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2926 |
String constant; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2927 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2928 |
public EnumConstant(String type, String constant) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2929 |
this.type = type; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2930 |
this.constant = constant; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2931 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2932 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2933 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2934 |
public String toString() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2935 |
return "e" + type + constant + ";"; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2936 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2937 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2938 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2939 |
public int hashCode() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2940 |
int hash = 7; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2941 |
hash = 19 * hash + Objects.hashCode(this.type); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2942 |
hash = 19 * hash + Objects.hashCode(this.constant); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2943 |
return hash; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2944 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2945 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2946 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2947 |
public boolean equals(Object obj) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2948 |
if (obj == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2949 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2950 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2951 |
if (getClass() != obj.getClass()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2952 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2953 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2954 |
final EnumConstant other = (EnumConstant) obj; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2955 |
if (!Objects.equals(this.type, other.type)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2956 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2957 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2958 |
if (!Objects.equals(this.constant, other.constant)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2959 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2960 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2961 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2962 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2963 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2964 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2965 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2966 |
static final class ClassConstant { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2967 |
String type; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2968 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2969 |
public ClassConstant(String type) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2970 |
this.type = type; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2971 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2972 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2973 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2974 |
public String toString() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2975 |
return "c" + type; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2976 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2977 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2978 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2979 |
public int hashCode() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2980 |
int hash = 3; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2981 |
hash = 53 * hash + Objects.hashCode(this.type); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2982 |
return hash; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2983 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2984 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2985 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2986 |
public boolean equals(Object obj) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2987 |
if (obj == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2988 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2989 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2990 |
if (getClass() != obj.getClass()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2991 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2992 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2993 |
final ClassConstant other = (ClassConstant) obj; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2994 |
if (!Objects.equals(this.type, other.type)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2995 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2996 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2997 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2998 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2999 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3000 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3001 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3002 |
static final class InnerClassInfo { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3003 |
String innerClass; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3004 |
String outerClass; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3005 |
String innerClassName; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3006 |
int innerClassFlags; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3007 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3008 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3009 |
public int hashCode() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3010 |
int hash = 3; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3011 |
hash = 11 * hash + Objects.hashCode(this.innerClass); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3012 |
hash = 11 * hash + Objects.hashCode(this.outerClass); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3013 |
hash = 11 * hash + Objects.hashCode(this.innerClassName); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3014 |
hash = 11 * hash + Objects.hashCode(this.innerClassFlags); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3015 |
return hash; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3016 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3017 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3018 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3019 |
public boolean equals(Object obj) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3020 |
if (obj == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3021 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3022 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3023 |
if (getClass() != obj.getClass()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3024 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3025 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3026 |
final InnerClassInfo other = (InnerClassInfo) obj; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3027 |
if (!Objects.equals(this.innerClass, other.innerClass)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3028 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3029 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3030 |
if (!Objects.equals(this.outerClass, other.outerClass)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3031 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3032 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3033 |
if (!Objects.equals(this.innerClassName, other.innerClassName)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3034 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3035 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3036 |
if (!Objects.equals(this.innerClassFlags, other.innerClassFlags)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3037 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3038 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3039 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3040 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3041 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3042 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3043 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3044 |
public static final class ClassList implements Iterable<ClassDescription> { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3045 |
private final List<ClassDescription> classes = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3046 |
private final Map<String, ClassDescription> name2Class = new HashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3047 |
private final Map<ClassDescription, ClassDescription> inner2Outter = new HashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3048 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3049 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3050 |
public Iterator<ClassDescription> iterator() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3051 |
return classes.iterator(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3052 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3053 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3054 |
public void add(ClassDescription desc) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3055 |
classes.add(desc); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3056 |
name2Class.put(desc.name, desc); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3057 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3058 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3059 |
public ClassDescription find(String name) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3060 |
return find(name, ALLOW_NON_EXISTING_CLASSES); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3061 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3062 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3063 |
public ClassDescription find(String name, boolean allowNull) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3064 |
ClassDescription desc = name2Class.get(name); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3065 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3066 |
if (desc != null || allowNull) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3067 |
return desc; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3068 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3069 |
throw new IllegalStateException("Cannot find: " + name); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3070 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3071 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3072 |
private static final ClassDescription NONE = new ClassDescription(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3073 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3074 |
public ClassDescription enclosingClass(ClassDescription clazz) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3075 |
if (clazz == null) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3076 |
return null; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3077 |
ClassDescription desc = inner2Outter.computeIfAbsent(clazz, c -> { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3078 |
ClassHeaderDescription header = clazz.header.get(0); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3079 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3080 |
if (header.innerClasses != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3081 |
for (InnerClassInfo ici : header.innerClasses) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3082 |
if (ici.innerClass.equals(clazz.name)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3083 |
return find(ici.outerClass); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3084 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3085 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3086 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3087 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3088 |
return NONE; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3089 |
}); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3090 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3091 |
return desc != NONE ? desc : null; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3092 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3093 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3094 |
public Iterable<ClassDescription> enclosingClasses(ClassDescription clazz) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3095 |
List<ClassDescription> result = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3096 |
ClassDescription outer = enclosingClass(clazz); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3097 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3098 |
while (outer != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3099 |
result.add(outer); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3100 |
outer = enclosingClass(outer); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3101 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3102 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3103 |
return result; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3104 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3105 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3106 |
public void sort() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3107 |
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
|
3108 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3109 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3110 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3111 |
private static int listHashCode(Collection<?> c) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3112 |
return c == null || c.isEmpty() ? 0 : c.hashCode(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3113 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3114 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3115 |
private static boolean listEquals(Collection<?> c1, Collection<?> c2) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3116 |
if (c1 == c2) return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3117 |
if (c1 == null && c2.isEmpty()) return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3118 |
if (c2 == null && c1.isEmpty()) return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3119 |
return Objects.equals(c1, c2); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3120 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3121 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3122 |
private static String serializeList(List<String> list) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3123 |
StringBuilder result = new StringBuilder(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3124 |
String sep = ""; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3125 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3126 |
for (Object o : list) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3127 |
result.append(sep); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3128 |
result.append(o); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3129 |
sep = ","; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3130 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3131 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3132 |
return quote(result.toString(), false); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3133 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3134 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3135 |
private static List<String> deserializeList(String serialized) { |
47703 | 3136 |
return deserializeList(serialized, true); |
3137 |
} |
|
3138 |
||
3139 |
private static List<String> deserializeList(String serialized, |
|
3140 |
boolean unquote) { |
|
3141 |
serialized = unquote ? unquote(serialized) : serialized; |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3142 |
if (serialized == null) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3143 |
return new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3144 |
return new ArrayList<>(Arrays.asList(serialized.split(","))); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3145 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3146 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3147 |
private static String quote(String value, boolean quoteQuotes) { |
47703 | 3148 |
return quote(value, quoteQuotes, false); |
3149 |
} |
|
3150 |
||
3151 |
private static String quote(String value, boolean quoteQuotes, |
|
3152 |
boolean quoteCommas) { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3153 |
StringBuilder result = new StringBuilder(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3154 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3155 |
for (char c : value.toCharArray()) { |
47703 | 3156 |
if (c <= 32 || c >= 127 || c == '\\' || |
3157 |
(quoteQuotes && c == '"') || (quoteCommas && c == ',')) { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3158 |
result.append("\\u" + String.format("%04X", (int) c) + ";"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3159 |
} else { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3160 |
result.append(c); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3161 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3162 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3163 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3164 |
return result.toString(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3165 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3166 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3167 |
private static final Pattern unicodePattern = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3168 |
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
|
3169 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3170 |
private static String unquote(String value) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3171 |
if (value == null) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3172 |
return null; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3173 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3174 |
StringBuilder result = new StringBuilder(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3175 |
Matcher m = unicodePattern.matcher(value); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3176 |
int lastStart = 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3177 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3178 |
while (m.find(lastStart)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3179 |
result.append(value.substring(lastStart, m.start())); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3180 |
result.append((char) Integer.parseInt(m.group(1), 16)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3181 |
lastStart = m.end() + 1; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3182 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3183 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3184 |
result.append(value.substring(lastStart, value.length())); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3185 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3186 |
return result.toString(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3187 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3188 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3189 |
private static String readDigits(String value, int[] valuePointer) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3190 |
int start = valuePointer[0]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3191 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3192 |
if (value.charAt(valuePointer[0]) == '-') |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3193 |
valuePointer[0]++; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3194 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3195 |
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
|
3196 |
valuePointer[0]++; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3197 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3198 |
return value.substring(start, valuePointer[0]); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3199 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3200 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3201 |
private static String className(String value, int[] valuePointer) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3202 |
int start = valuePointer[0]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3203 |
while (value.charAt(valuePointer[0]++) != ';') |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3204 |
; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3205 |
return value.substring(start, valuePointer[0]); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3206 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3207 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3208 |
private static Object parseAnnotationValue(String value, int[] valuePointer) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3209 |
switch (value.charAt(valuePointer[0]++)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3210 |
case 'Z': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3211 |
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
|
3212 |
valuePointer[0] += 4; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3213 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3214 |
} 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
|
3215 |
valuePointer[0] += 5; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3216 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3217 |
} else { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3218 |
throw new IllegalStateException("Unrecognized boolean structure: " + value); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3219 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3220 |
case 'B': return Byte.parseByte(readDigits(value, valuePointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3221 |
case 'C': return value.charAt(valuePointer[0]++); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3222 |
case 'S': return Short.parseShort(readDigits(value, valuePointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3223 |
case 'I': return Integer.parseInt(readDigits(value, valuePointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3224 |
case 'J': return Long.parseLong(readDigits(value, valuePointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3225 |
case 'F': return Float.parseFloat(readDigits(value, valuePointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3226 |
case 'D': return Double.parseDouble(readDigits(value, valuePointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3227 |
case 'c': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3228 |
return new ClassConstant(className(value, valuePointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3229 |
case 'e': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3230 |
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
|
3231 |
case '{': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3232 |
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
|
3233 |
while (value.charAt(valuePointer[0]) != '}') { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3234 |
elements.add(parseAnnotationValue(value, valuePointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3235 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3236 |
valuePointer[0]++; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3237 |
return elements; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3238 |
case '"': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3239 |
int start = valuePointer[0]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3240 |
while (value.charAt(valuePointer[0]) != '"') |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3241 |
valuePointer[0]++; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3242 |
return unquote(value.substring(start, valuePointer[0]++)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3243 |
case '@': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3244 |
return parseAnnotation(value, valuePointer); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3245 |
default: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3246 |
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
|
3247 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3248 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3249 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3250 |
public static List<AnnotationDescription> parseAnnotations(String encoded, int[] pointer) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3251 |
ArrayList<AnnotationDescription> result = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3252 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3253 |
while (pointer[0] < encoded.length() && encoded.charAt(pointer[0]) == '@') { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3254 |
pointer[0]++; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3255 |
result.add(parseAnnotation(encoded, pointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3256 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3257 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3258 |
return result; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3259 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3260 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3261 |
private static AnnotationDescription parseAnnotation(String value, int[] valuePointer) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3262 |
String className = className(value, valuePointer); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3263 |
Map<String, Object> attribute2Value = new HashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3264 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3265 |
if (valuePointer[0] < value.length() && value.charAt(valuePointer[0]) == '(') { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3266 |
while (value.charAt(valuePointer[0]) != ')') { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3267 |
int nameStart = ++valuePointer[0]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3268 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3269 |
while (value.charAt(valuePointer[0]++) != '='); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3270 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3271 |
String name = value.substring(nameStart, valuePointer[0] - 1); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3272 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3273 |
attribute2Value.put(name, parseAnnotationValue(value, valuePointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3274 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3275 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3276 |
valuePointer[0]++; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3277 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3278 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3279 |
return new AnnotationDescription(className, attribute2Value); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3280 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3281 |
//</editor-fold> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3282 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3283 |
private static void help() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3284 |
System.err.println("Help..."); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3285 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3286 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3287 |
public static void main(String... args) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3288 |
if (args.length < 1) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3289 |
help(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3290 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3291 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3292 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3293 |
switch (args[0]) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3294 |
case "build-description": |
47703 | 3295 |
if (args.length < 3) { |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3296 |
help(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3297 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3298 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3299 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3300 |
Path descDest = Paths.get(args[1]); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3301 |
List<VersionDescription> versions = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3302 |
|
47703 | 3303 |
for (int i = 3; i + 2 < args.length; i += 3) { |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3304 |
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
|
3305 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3306 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3307 |
Files.walkFileTree(descDest, new FileVisitor<Path>() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3308 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3309 |
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3310 |
return FileVisitResult.CONTINUE; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3311 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3312 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3313 |
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3314 |
Files.delete(file); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3315 |
return FileVisitResult.CONTINUE; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3316 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3317 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3318 |
public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3319 |
return FileVisitResult.CONTINUE; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3320 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3321 |
@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
|
3322 |
Files.delete(dir); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3323 |
return FileVisitResult.CONTINUE; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3324 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3325 |
}); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3326 |
|
47703 | 3327 |
ExcludeIncludeList excludeList = |
3328 |
ExcludeIncludeList.create(args[2]); |
|
3329 |
||
3330 |
new CreateSymbols().createBaseLine(versions, |
|
3331 |
excludeList, |
|
3332 |
descDest, |
|
3333 |
args); |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3334 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3335 |
case "build-ctsym": |
47703 | 3336 |
if (args.length != 3) { |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3337 |
help(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3338 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3339 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3340 |
|
47703 | 3341 |
new CreateSymbols().createSymbols(args[1], |
3342 |
args[2], |
|
3343 |
CtSymKind.JOINED_VERSIONS); |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3344 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3345 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3346 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3347 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3348 |
} |