author | ihse |
Mon, 03 Dec 2018 18:33:11 +0100 | |
branch | ihse-manpages-branch |
changeset 57051 | d8697832a650 |
parent 51832 | bf1d479fe7eb |
child 53696 | f0f8f0afed74 |
permissions | -rw-r--r-- |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1 |
/* |
50027 | 2 |
* Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved. |
31506
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; |
|
50027 | 34 |
import java.io.BufferedInputStream; |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
35 |
import java.io.BufferedReader; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
36 |
import java.io.ByteArrayInputStream; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
37 |
import java.io.ByteArrayOutputStream; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
38 |
import java.io.File; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
39 |
import java.io.IOException; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
40 |
import java.io.InputStream; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
41 |
import java.io.OutputStream; |
50027 | 42 |
import java.io.StringWriter; |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
43 |
import java.io.Writer; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
44 |
import java.nio.file.Files; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
45 |
import java.nio.file.FileVisitResult; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
46 |
import java.nio.file.FileVisitor; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
47 |
import java.nio.file.Path; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
48 |
import java.nio.file.Paths; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
49 |
import java.nio.file.attribute.BasicFileAttributes; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
50 |
import java.util.stream.Stream; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
51 |
import java.util.ArrayList; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
52 |
import java.util.Arrays; |
50027 | 53 |
import java.util.Calendar; |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
54 |
import java.util.Collection; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
55 |
import java.util.Collections; |
50027 | 56 |
import java.util.EnumSet; |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
57 |
import java.util.HashMap; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
58 |
import java.util.HashSet; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
59 |
import java.util.Iterator; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
60 |
import java.util.LinkedHashMap; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
61 |
import java.util.List; |
50027 | 62 |
import java.util.Locale; |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
63 |
import java.util.Map; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
64 |
import java.util.Map.Entry; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
65 |
import java.util.Objects; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
66 |
import java.util.Set; |
50027 | 67 |
import java.util.TimeZone; |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
68 |
import java.util.function.Function; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
69 |
import java.util.function.Predicate; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
70 |
import java.util.regex.Matcher; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
71 |
import java.util.regex.Pattern; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
72 |
import java.util.stream.Collectors; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
73 |
|
50027 | 74 |
import javax.tools.JavaFileManager; |
75 |
import javax.tools.JavaFileManager.Location; |
|
76 |
import javax.tools.JavaFileObject; |
|
77 |
import javax.tools.JavaFileObject.Kind; |
|
78 |
import javax.tools.StandardLocation; |
|
79 |
||
80 |
import com.sun.source.util.JavacTask; |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
81 |
import com.sun.tools.classfile.AccessFlags; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
82 |
import com.sun.tools.classfile.Annotation; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
83 |
import com.sun.tools.classfile.Annotation.Annotation_element_value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
84 |
import com.sun.tools.classfile.Annotation.Array_element_value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
85 |
import com.sun.tools.classfile.Annotation.Class_element_value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
86 |
import com.sun.tools.classfile.Annotation.Enum_element_value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
87 |
import com.sun.tools.classfile.Annotation.Primitive_element_value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
88 |
import com.sun.tools.classfile.Annotation.element_value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
89 |
import com.sun.tools.classfile.Annotation.element_value_pair; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
90 |
import com.sun.tools.classfile.AnnotationDefault_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
91 |
import com.sun.tools.classfile.Attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
92 |
import com.sun.tools.classfile.Attributes; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
93 |
import com.sun.tools.classfile.ClassFile; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
94 |
import com.sun.tools.classfile.ClassWriter; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
95 |
import com.sun.tools.classfile.ConstantPool; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
96 |
import com.sun.tools.classfile.ConstantPool.CONSTANT_Class_info; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
97 |
import com.sun.tools.classfile.ConstantPool.CONSTANT_Double_info; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
98 |
import com.sun.tools.classfile.ConstantPool.CONSTANT_Float_info; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
99 |
import com.sun.tools.classfile.ConstantPool.CONSTANT_Integer_info; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
100 |
import com.sun.tools.classfile.ConstantPool.CONSTANT_Long_info; |
47703 | 101 |
import com.sun.tools.classfile.ConstantPool.CONSTANT_Module_info; |
102 |
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
|
103 |
import com.sun.tools.classfile.ConstantPool.CONSTANT_String_info; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
104 |
import com.sun.tools.classfile.ConstantPool.CONSTANT_Utf8_info; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
105 |
import com.sun.tools.classfile.ConstantPool.CPInfo; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
106 |
import com.sun.tools.classfile.ConstantPool.InvalidIndex; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
107 |
import com.sun.tools.classfile.ConstantPoolException; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
108 |
import com.sun.tools.classfile.ConstantValue_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
109 |
import com.sun.tools.classfile.Deprecated_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
110 |
import com.sun.tools.classfile.Descriptor; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
111 |
import com.sun.tools.classfile.Exceptions_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
112 |
import com.sun.tools.classfile.Field; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
113 |
import com.sun.tools.classfile.InnerClasses_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
114 |
import com.sun.tools.classfile.InnerClasses_attribute.Info; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
115 |
import com.sun.tools.classfile.Method; |
47703 | 116 |
import com.sun.tools.classfile.ModuleResolution_attribute; |
117 |
import com.sun.tools.classfile.ModuleTarget_attribute; |
|
118 |
import com.sun.tools.classfile.Module_attribute; |
|
119 |
import com.sun.tools.classfile.Module_attribute.ExportsEntry; |
|
120 |
import com.sun.tools.classfile.Module_attribute.OpensEntry; |
|
121 |
import com.sun.tools.classfile.Module_attribute.ProvidesEntry; |
|
122 |
import com.sun.tools.classfile.Module_attribute.RequiresEntry; |
|
51799 | 123 |
import com.sun.tools.classfile.NestHost_attribute; |
124 |
import com.sun.tools.classfile.NestMembers_attribute; |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
125 |
import com.sun.tools.classfile.RuntimeAnnotations_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
126 |
import com.sun.tools.classfile.RuntimeInvisibleAnnotations_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
127 |
import com.sun.tools.classfile.RuntimeInvisibleParameterAnnotations_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
128 |
import com.sun.tools.classfile.RuntimeParameterAnnotations_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
129 |
import com.sun.tools.classfile.RuntimeVisibleAnnotations_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
130 |
import com.sun.tools.classfile.RuntimeVisibleParameterAnnotations_attribute; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
131 |
import com.sun.tools.classfile.Signature_attribute; |
50027 | 132 |
import com.sun.tools.javac.api.JavacTool; |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
133 |
import com.sun.tools.javac.jvm.Target; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
134 |
import com.sun.tools.javac.util.Assert; |
50027 | 135 |
import com.sun.tools.javac.util.Context; |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
136 |
import com.sun.tools.javac.util.Pair; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
137 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
138 |
/** |
51799 | 139 |
* A tool for processing the .sym.txt files. |
140 |
* |
|
141 |
* To add historical data for JDK N, N >= 11, do the following: |
|
142 |
* * cd <open-jdk-checkout>/make/data/symbols |
|
143 |
* * <jdk-N>/bin/java --add-exports jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED \ |
|
144 |
* --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \ |
|
145 |
* --add-exports jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED \ |
|
146 |
* --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED \ |
|
147 |
* --add-modules jdk.jdeps \ |
|
148 |
* ../../../make/langtools/src/classes/build/tools/symbolgenerator/CreateSymbols.java \ |
|
149 |
* build-description-incremental symbols include.list |
|
150 |
* * sanity-check the new and updates files in make/data/symbols and commit them |
|
151 |
* |
|
152 |
* The tools allows to: |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
153 |
* * 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
|
154 |
* * in cooperation with the adjacent history Probe, construct .sym.txt files for previous platforms |
50027 | 155 |
* * enhance existing .sym.txt files with a a new set .sym.txt for the current platform |
31506
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 |
* To convert the .sym.txt files to class/sig files from ct.sym, run: |
50027 | 158 |
* java build.tool.symbolgenerator.CreateSymbols build-ctsym <platform-description-file> <target-directory> |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
159 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
160 |
* 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
|
161 |
* generate platforms <platform-ids-to-generate separate with ':'> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
162 |
* 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
|
163 |
* 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
|
164 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
165 |
* 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
|
166 |
* 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
|
167 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
168 |
* 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
|
169 |
* <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
|
170 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
171 |
* 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
|
172 |
* will be written. |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
173 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
174 |
* 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
|
175 |
* 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
|
176 |
* <platform-id1> <target-file-for-platform1> "<none>" |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
177 |
* <platform-id2> <target-file-for-platform2> <diff-against-platform2> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
178 |
* <platform-id3> <target-file-for-platform3> <diff-against-platform3> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
179 |
* ... |
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 |
* 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
|
182 |
* 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
|
183 |
* 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
|
184 |
* 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
|
185 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
186 |
* 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
|
187 |
* 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
|
188 |
* 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
|
189 |
* 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
|
190 |
* 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
|
191 |
* 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
|
192 |
* <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
|
193 |
* 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
|
194 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
195 |
* 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
|
196 |
* <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
|
197 |
* <jdk-8>/bin/java build.tools.symbolgenerator.Probe OpenJDK8.classes |
50027 | 198 |
* java build.tools.symbolgenerator.CreateSymbols build-description make/data/symbols $TOPDIR make/data/symbols/include.list |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
199 |
* 8 OpenJDK8.classes '<none>' |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
200 |
* 7 OpenJDK7.classes 8 |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
201 |
* |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
202 |
* Note: the versions are expected to be a single character. |
50027 | 203 |
* |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
204 |
*/ |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
205 |
public class CreateSymbols { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
206 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
207 |
//<editor-fold defaultstate="collapsed" desc="ct.sym construction"> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
208 |
/**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
|
209 |
* {@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
|
210 |
*/ |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
211 |
@SuppressWarnings("unchecked") |
51832
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
212 |
public void createSymbols(String ctDescriptionFileExtra, String ctDescriptionFile, String ctSymLocation) throws IOException { |
51799 | 213 |
LoadDescriptions data = load(ctDescriptionFileExtra != null ? Paths.get(ctDescriptionFileExtra) |
214 |
: null, |
|
215 |
Paths.get(ctDescriptionFile), null); |
|
50027 | 216 |
|
217 |
splitHeaders(data.classes); |
|
218 |
||
51832
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
219 |
Map<String, Map<Character, String>> package2Version2Module = new HashMap<>(); |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
220 |
|
50027 | 221 |
for (ModuleDescription md : data.modules.values()) { |
47703 | 222 |
for (ModuleHeaderDescription mhd : md.header) { |
223 |
List<String> versionsList = |
|
224 |
Collections.singletonList(mhd.versions); |
|
225 |
writeModulesForVersions(ctSymLocation, |
|
226 |
md, |
|
227 |
mhd, |
|
228 |
versionsList); |
|
51832
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
229 |
mhd.exports.stream().forEach(pkg -> { |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
230 |
for (char v : mhd.versions.toCharArray()) { |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
231 |
package2Version2Module.computeIfAbsent(pkg, dummy -> new HashMap<>()).put(v, md.name); |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
232 |
} |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
233 |
}); |
47703 | 234 |
} |
235 |
} |
|
236 |
||
50027 | 237 |
for (ClassDescription classDescription : data.classes) { |
51832
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
238 |
Map<Character, String> version2Module = package2Version2Module.getOrDefault(classDescription.packge().replace('.', '/'), Collections.emptyMap()); |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
239 |
for (ClassHeaderDescription header : classDescription.header) { |
51832
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
240 |
Set<String> jointVersions = new HashSet<>(); |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
241 |
jointVersions.add(header.versions); |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
242 |
limitJointVersion(jointVersions, classDescription.fields); |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
243 |
limitJointVersion(jointVersions, classDescription.methods); |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
244 |
Map<String, StringBuilder> module2Versions = new HashMap<>(); |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
245 |
for (char v : header.versions.toCharArray()) { |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
246 |
String module = version2Module.get(v); |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
247 |
if (module == null) { |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
248 |
if (v >= '9') { |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
249 |
throw new AssertionError("No module for " + classDescription.name + |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
250 |
" and version " + v); |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
251 |
} |
51832
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
252 |
module = version2Module.get('9'); |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
253 |
if (module == null) { |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
254 |
module = "java.base"; |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
255 |
} |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
256 |
} |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
257 |
module2Versions.computeIfAbsent(module, dummy -> new StringBuilder()).append(v); |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
258 |
} |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
259 |
for (Entry<String, StringBuilder> e : module2Versions.entrySet()) { |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
260 |
Set<String> currentVersions = new HashSet<>(jointVersions); |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
261 |
limitJointVersion(currentVersions, e.getValue().toString()); |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
262 |
currentVersions = currentVersions.stream().filter(vers -> !disjoint(vers, e.getValue().toString())).collect(Collectors.toSet()); |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
263 |
writeClassesForVersions(ctSymLocation, classDescription, header, e.getKey(), currentVersions); |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
264 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
265 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
266 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
267 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
268 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
269 |
public static String EXTENSION = ".sig"; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
270 |
|
51799 | 271 |
LoadDescriptions load(Path ctDescriptionWithExtraContent, Path ctDescriptionOpen, String deletePlatform) throws IOException { |
272 |
Map<String, PlatformInput> platforms = new LinkedHashMap<>(); |
|
273 |
||
274 |
if (ctDescriptionWithExtraContent != null && Files.isRegularFile(ctDescriptionWithExtraContent)) { |
|
275 |
try (LineBasedReader reader = new LineBasedReader(ctDescriptionWithExtraContent)) { |
|
276 |
while (reader.hasNext()) { |
|
277 |
switch (reader.lineKey) { |
|
278 |
case "generate": |
|
279 |
//ignore |
|
280 |
reader.moveNext(); |
|
281 |
break; |
|
282 |
case "platform": |
|
283 |
PlatformInput platform = PlatformInput.load(ctDescriptionWithExtraContent, |
|
284 |
reader); |
|
285 |
if (!platform.version.equals(deletePlatform)) |
|
286 |
platforms.put(platform.version, platform); |
|
287 |
reader.moveNext(); |
|
288 |
break; |
|
289 |
default: |
|
290 |
throw new IllegalStateException("Unknown key: " + reader.lineKey); |
|
291 |
} |
|
292 |
} |
|
293 |
} |
|
294 |
} |
|
295 |
||
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
296 |
Set<String> generatePlatforms = null; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
297 |
|
51799 | 298 |
try (LineBasedReader reader = new LineBasedReader(ctDescriptionOpen)) { |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
299 |
while (reader.hasNext()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
300 |
switch (reader.lineKey) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
301 |
case "generate": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
302 |
String[] platformsAttr = reader.attributes.get("platforms").split(":"); |
50027 | 303 |
generatePlatforms = new HashSet<>(List.of(platformsAttr)); |
304 |
generatePlatforms.remove(deletePlatform); |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
305 |
reader.moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
306 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
307 |
case "platform": |
51799 | 308 |
PlatformInput platform = PlatformInput.load(ctDescriptionOpen, reader); |
309 |
if (!platform.version.equals(deletePlatform) && |
|
310 |
!platforms.containsKey(platform.version)) |
|
311 |
platforms.put(platform.version, platform); |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
312 |
reader.moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
313 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
314 |
default: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
315 |
throw new IllegalStateException("Unknown key: " + reader.lineKey); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
316 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
317 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
318 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
319 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
320 |
Map<String, ClassDescription> classes = new LinkedHashMap<>(); |
47703 | 321 |
Map<String, ModuleDescription> modules = new LinkedHashMap<>(); |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
322 |
|
51799 | 323 |
for (PlatformInput platform : platforms.values()) { |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
324 |
for (ClassDescription cd : classes.values()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
325 |
addNewVersion(cd.header, platform.basePlatform, platform.version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
326 |
addNewVersion(cd.fields, platform.basePlatform, platform.version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
327 |
addNewVersion(cd.methods, platform.basePlatform, platform.version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
328 |
} |
50027 | 329 |
for (ModuleDescription md : modules.values()) { |
330 |
addNewVersion(md.header, platform.basePlatform, platform.version); |
|
331 |
} |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
332 |
for (String input : platform.files) { |
51799 | 333 |
Path inputFile = platform.ctDescription.getParent().resolve(input); |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
334 |
try (LineBasedReader reader = new LineBasedReader(inputFile)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
335 |
while (reader.hasNext()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
336 |
String nameAttr = reader.attributes.get("name"); |
47703 | 337 |
switch (reader.lineKey) { |
338 |
case "class": case "-class": |
|
339 |
ClassDescription cd = |
|
340 |
classes.computeIfAbsent(nameAttr, |
|
341 |
n -> new ClassDescription()); |
|
342 |
if ("-class".equals(reader.lineKey)) { |
|
343 |
removeVersion(cd.header, h -> true, |
|
344 |
platform.version); |
|
345 |
reader.moveNext(); |
|
346 |
continue; |
|
347 |
} |
|
348 |
cd.read(reader, platform.basePlatform, |
|
349 |
platform.version); |
|
350 |
break; |
|
50027 | 351 |
case "module": { |
47703 | 352 |
ModuleDescription md = |
353 |
modules.computeIfAbsent(nameAttr, |
|
354 |
n -> new ModuleDescription()); |
|
355 |
md.read(reader, platform.basePlatform, |
|
356 |
platform.version); |
|
357 |
break; |
|
50027 | 358 |
} |
359 |
case "-module": { |
|
360 |
ModuleDescription md = |
|
361 |
modules.computeIfAbsent(nameAttr, |
|
362 |
n -> new ModuleDescription()); |
|
363 |
removeVersion(md.header, h -> true, |
|
364 |
platform.version); |
|
365 |
reader.moveNext(); |
|
366 |
break; |
|
367 |
} |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
368 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
369 |
} |
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 |
} |
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 |
ClassList result = new ClassList(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
375 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
376 |
for (ClassDescription desc : classes.values()) { |
47703 | 377 |
Iterator<ClassHeaderDescription> chdIt = desc.header.iterator(); |
378 |
||
379 |
while (chdIt.hasNext()) { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
380 |
ClassHeaderDescription chd = chdIt.next(); |
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 |
chd.versions = reduce(chd.versions, generatePlatforms); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
383 |
if (chd.versions.isEmpty()) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
384 |
chdIt.remove(); |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
387 |
if (desc.header.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
388 |
continue; |
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 |
|
47703 | 391 |
Iterator<MethodDescription> methodIt = desc.methods.iterator(); |
392 |
||
393 |
while (methodIt.hasNext()) { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
394 |
MethodDescription method = methodIt.next(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
395 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
396 |
method.versions = reduce(method.versions, generatePlatforms); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
397 |
if (method.versions.isEmpty()) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
398 |
methodIt.remove(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
399 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
400 |
|
47703 | 401 |
Iterator<FieldDescription> fieldIt = desc.fields.iterator(); |
402 |
||
403 |
while (fieldIt.hasNext()) { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
404 |
FieldDescription field = fieldIt.next(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
405 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
406 |
field.versions = reduce(field.versions, generatePlatforms); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
407 |
if (field.versions.isEmpty()) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
408 |
fieldIt.remove(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
409 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
410 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
411 |
result.add(desc); |
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 |
|
50027 | 414 |
Map<String, ModuleDescription> moduleList = new HashMap<>(); |
47703 | 415 |
|
416 |
for (ModuleDescription desc : modules.values()) { |
|
417 |
Iterator<ModuleHeaderDescription> mhdIt = desc.header.iterator(); |
|
418 |
||
419 |
while (mhdIt.hasNext()) { |
|
420 |
ModuleHeaderDescription mhd = mhdIt.next(); |
|
421 |
||
422 |
mhd.versions = reduce(mhd.versions, generatePlatforms); |
|
423 |
if (mhd.versions.isEmpty()) |
|
424 |
mhdIt.remove(); |
|
425 |
} |
|
426 |
||
427 |
if (desc.header.isEmpty()) { |
|
428 |
continue; |
|
429 |
} |
|
430 |
||
50027 | 431 |
moduleList.put(desc.name, desc); |
47703 | 432 |
} |
433 |
||
51799 | 434 |
return new LoadDescriptions(result, moduleList, new ArrayList<>(platforms.values())); |
50027 | 435 |
} |
436 |
||
437 |
static final class LoadDescriptions { |
|
438 |
public final ClassList classes; |
|
439 |
public final Map<String, ModuleDescription> modules; |
|
440 |
public final List<PlatformInput> versions; |
|
441 |
||
442 |
public LoadDescriptions(ClassList classes, |
|
443 |
Map<String, ModuleDescription> modules, |
|
444 |
List<PlatformInput> versions) { |
|
445 |
this.classes = classes; |
|
446 |
this.modules = modules; |
|
447 |
this.versions = versions; |
|
448 |
} |
|
449 |
||
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
450 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
451 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
452 |
static final class LineBasedReader implements AutoCloseable { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
453 |
private final BufferedReader input; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
454 |
public String lineKey; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
455 |
public Map<String, String> attributes = new HashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
456 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
457 |
public LineBasedReader(Path input) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
458 |
this.input = Files.newBufferedReader(input); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
459 |
moveNext(); |
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 |
public void moveNext() throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
463 |
String line = input.readLine(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
464 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
465 |
if (line == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
466 |
lineKey = null; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
467 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
468 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
469 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
470 |
if (line.trim().isEmpty() || line.startsWith("#")) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
471 |
moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
472 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
473 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
474 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
475 |
String[] parts = line.split(" "); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
476 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
477 |
lineKey = parts[0]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
478 |
attributes.clear(); |
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 |
for (int i = 1; i < parts.length; i += 2) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
481 |
attributes.put(parts[i], unquote(parts[i + 1])); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
482 |
} |
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 |
public boolean hasNext() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
486 |
return lineKey != null; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
487 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
488 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
489 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
490 |
public void close() throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
491 |
input.close(); |
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 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
494 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
495 |
private static String reduce(String original, String other) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
496 |
Set<String> otherSet = new HashSet<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
497 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
498 |
for (char v : other.toCharArray()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
499 |
otherSet.add("" + v); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
500 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
501 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
502 |
return reduce(original, otherSet); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
503 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
504 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
505 |
private static String reduce(String original, Set<String> generate) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
506 |
StringBuilder sb = new StringBuilder(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
507 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
508 |
for (char v : original.toCharArray()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
509 |
if (generate.contains("" + v)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
510 |
sb.append(v); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
511 |
} |
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 |
return sb.toString(); |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
516 |
private static class PlatformInput { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
517 |
public final String version; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
518 |
public final String basePlatform; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
519 |
public final List<String> files; |
51799 | 520 |
public final Path ctDescription; |
521 |
public PlatformInput(Path ctDescription, String version, String basePlatform, List<String> files) { |
|
522 |
this.ctDescription = ctDescription; |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
523 |
this.version = version; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
524 |
this.basePlatform = basePlatform; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
525 |
this.files = files; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
526 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
527 |
|
51799 | 528 |
public static PlatformInput load(Path ctDescription, LineBasedReader in) throws IOException { |
529 |
return new PlatformInput(ctDescription, |
|
530 |
in.attributes.get("version"), |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
531 |
in.attributes.get("base"), |
50027 | 532 |
List.of(in.attributes.get("files").split(":"))); |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
533 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
534 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
535 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
536 |
static void addNewVersion(Collection<? extends FeatureDescription> features, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
537 |
String baselineVersion, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
538 |
String version) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
539 |
features.stream() |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
540 |
.filter(f -> f.versions.contains(baselineVersion)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
541 |
.forEach(f -> f.versions += version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
542 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
543 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
544 |
static <T extends FeatureDescription> void removeVersion(Collection<T> features, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
545 |
Predicate<T> shouldRemove, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
546 |
String version) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
547 |
for (T existing : features) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
548 |
if (shouldRemove.test(existing) && existing.versions.endsWith(version)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
549 |
existing.versions = existing.versions.replace(version, ""); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
550 |
return; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
551 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
552 |
} |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
555 |
/**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
|
556 |
* 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
|
557 |
* 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
|
558 |
*/ |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
559 |
static void splitHeaders(ClassList classes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
560 |
Set<String> ctVersions = new HashSet<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
561 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
562 |
for (ClassDescription cd : classes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
563 |
for (ClassHeaderDescription header : cd.header) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
564 |
for (char c : header.versions.toCharArray()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
565 |
ctVersions.add("" + c); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
566 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
567 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
568 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
569 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
570 |
classes.sort(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
571 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
572 |
for (ClassDescription cd : classes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
573 |
Map<String, String> outerSignatures2Version = new HashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
574 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
575 |
for (String version : ctVersions) { //XXX |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
576 |
ClassDescription outer = cd; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
577 |
String outerSignatures = ""; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
578 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
579 |
while ((outer = classes.enclosingClass(outer)) != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
580 |
for (ClassHeaderDescription outerHeader : outer.header) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
581 |
if (outerHeader.versions.contains(version)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
582 |
outerSignatures += outerHeader.signature; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
583 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
584 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
585 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
586 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
587 |
outerSignatures2Version.compute(outerSignatures, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
588 |
(key, value) -> value != null ? value + version : version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
589 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
590 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
591 |
List<ClassHeaderDescription> newHeaders = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
592 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
593 |
HEADER_LOOP: for (ClassHeaderDescription header : cd.header) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
594 |
for (String versions : outerSignatures2Version.values()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
595 |
if (containsAll(versions, header.versions)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
596 |
newHeaders.add(header); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
597 |
continue HEADER_LOOP; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
598 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
599 |
if (disjoint(versions, header.versions)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
600 |
continue; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
601 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
602 |
ClassHeaderDescription newHeader = new ClassHeaderDescription(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
603 |
newHeader.classAnnotations = header.classAnnotations; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
604 |
newHeader.deprecated = header.deprecated; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
605 |
newHeader.extendsAttr = header.extendsAttr; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
606 |
newHeader.flags = header.flags; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
607 |
newHeader.implementsAttr = header.implementsAttr; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
608 |
newHeader.innerClasses = header.innerClasses; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
609 |
newHeader.runtimeAnnotations = header.runtimeAnnotations; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
610 |
newHeader.signature = header.signature; |
51832
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
611 |
newHeader.versions = reduce(header.versions, versions); |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
612 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
613 |
newHeaders.add(newHeader); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
614 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
615 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
616 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
617 |
cd.header = newHeaders; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
618 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
619 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
620 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
621 |
void limitJointVersion(Set<String> jointVersions, List<? extends FeatureDescription> features) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
622 |
for (FeatureDescription feature : features) { |
51832
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
623 |
limitJointVersion(jointVersions, feature.versions); |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
624 |
} |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
625 |
} |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
626 |
|
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
627 |
void limitJointVersion(Set<String> jointVersions, String versions) { |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
628 |
for (String version : jointVersions) { |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
629 |
if (!containsAll(versions, version) && |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
630 |
!disjoint(versions, version)) { |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
631 |
StringBuilder featurePart = new StringBuilder(); |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
632 |
StringBuilder otherPart = new StringBuilder(); |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
633 |
for (char v : version.toCharArray()) { |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
634 |
if (versions.indexOf(v) != (-1)) { |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
635 |
featurePart.append(v); |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
636 |
} else { |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
637 |
otherPart.append(v); |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
638 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
639 |
} |
51832
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
640 |
jointVersions.remove(version); |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
641 |
if (featurePart.length() == 0 || otherPart.length() == 0) { |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
642 |
throw new AssertionError(); |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
643 |
} |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
644 |
jointVersions.add(featurePart.toString()); |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
645 |
jointVersions.add(otherPart.toString()); |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
646 |
break; |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
647 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
648 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
649 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
650 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
651 |
private static boolean containsAll(String versions, String subVersions) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
652 |
for (char c : subVersions.toCharArray()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
653 |
if (versions.indexOf(c) == (-1)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
654 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
655 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
656 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
657 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
658 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
659 |
private static boolean disjoint(String version1, String version2) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
660 |
for (char c : version2.toCharArray()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
661 |
if (version1.indexOf(c) != (-1)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
662 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
663 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
664 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
665 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
666 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
667 |
void writeClassesForVersions(String ctSymLocation, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
668 |
ClassDescription classDescription, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
669 |
ClassHeaderDescription header, |
51832
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
670 |
String module, |
47703 | 671 |
Iterable<String> versions) |
672 |
throws IOException { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
673 |
for (String ver : versions) { |
51832
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
674 |
writeClass(ctSymLocation, classDescription, header, module, ver); |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
675 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
676 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
677 |
|
47703 | 678 |
void writeModulesForVersions(String ctSymLocation, |
679 |
ModuleDescription moduleDescription, |
|
680 |
ModuleHeaderDescription header, |
|
681 |
Iterable<String> versions) |
|
682 |
throws IOException { |
|
683 |
for (String ver : versions) { |
|
684 |
writeModule(ctSymLocation, moduleDescription, header, ver); |
|
685 |
} |
|
686 |
} |
|
687 |
||
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
688 |
//<editor-fold defaultstate="collapsed" desc="Class Writing"> |
47703 | 689 |
void writeModule(String ctSymLocation, |
690 |
ModuleDescription moduleDescription, |
|
691 |
ModuleHeaderDescription header, |
|
692 |
String version) throws IOException { |
|
693 |
List<CPInfo> constantPool = new ArrayList<>(); |
|
694 |
constantPool.add(null); |
|
695 |
int currentClass = addClass(constantPool, "module-info"); |
|
696 |
int superclass = 0; |
|
697 |
int[] interfaces = new int[0]; |
|
698 |
AccessFlags flags = new AccessFlags(header.flags); |
|
699 |
Map<String, Attribute> attributesMap = new HashMap<>(); |
|
700 |
addAttributes(moduleDescription, header, constantPool, attributesMap); |
|
701 |
Attributes attributes = new Attributes(attributesMap); |
|
702 |
CPInfo[] cpData = constantPool.toArray(new CPInfo[constantPool.size()]); |
|
703 |
ConstantPool cp = new ConstantPool(cpData); |
|
704 |
ClassFile classFile = new ClassFile(0xCAFEBABE, |
|
705 |
Target.DEFAULT.minorVersion, |
|
706 |
Target.DEFAULT.majorVersion, |
|
707 |
cp, |
|
708 |
flags, |
|
709 |
currentClass, |
|
710 |
superclass, |
|
711 |
interfaces, |
|
712 |
new Field[0], |
|
713 |
new Method[0], |
|
714 |
attributes); |
|
715 |
||
716 |
Path outputClassFile = Paths.get(ctSymLocation, |
|
51832
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
717 |
version, |
47703 | 718 |
moduleDescription.name, |
719 |
"module-info" + EXTENSION); |
|
720 |
||
721 |
Files.createDirectories(outputClassFile.getParent()); |
|
722 |
||
723 |
try (OutputStream out = Files.newOutputStream(outputClassFile)) { |
|
724 |
ClassWriter w = new ClassWriter(); |
|
725 |
||
726 |
w.write(classFile, out); |
|
727 |
} |
|
728 |
} |
|
729 |
||
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
730 |
void writeClass(String ctSymLocation, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
731 |
ClassDescription classDescription, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
732 |
ClassHeaderDescription header, |
51832
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
733 |
String module, |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
734 |
String version) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
735 |
List<CPInfo> constantPool = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
736 |
constantPool.add(null); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
737 |
List<Method> methods = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
738 |
for (MethodDescription methDesc : classDescription.methods) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
739 |
if (disjoint(methDesc.versions, version)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
740 |
continue; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
741 |
Descriptor descriptor = new Descriptor(addString(constantPool, methDesc.descriptor)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
742 |
//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
|
743 |
Map<String, Attribute> attributesMap = new LinkedHashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
744 |
addAttributes(methDesc, constantPool, attributesMap); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
745 |
Attributes attributes = new Attributes(attributesMap); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
746 |
AccessFlags flags = new AccessFlags(methDesc.flags); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
747 |
int nameString = addString(constantPool, methDesc.name); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
748 |
methods.add(new Method(flags, nameString, descriptor, attributes)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
749 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
750 |
List<Field> fields = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
751 |
for (FieldDescription fieldDesc : classDescription.fields) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
752 |
if (disjoint(fieldDesc.versions, version)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
753 |
continue; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
754 |
Descriptor descriptor = new Descriptor(addString(constantPool, fieldDesc.descriptor)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
755 |
Map<String, Attribute> attributesMap = new HashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
756 |
addAttributes(fieldDesc, constantPool, attributesMap); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
757 |
Attributes attributes = new Attributes(attributesMap); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
758 |
AccessFlags flags = new AccessFlags(fieldDesc.flags); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
759 |
int nameString = addString(constantPool, fieldDesc.name); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
760 |
fields.add(new Field(flags, nameString, descriptor, attributes)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
761 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
762 |
int currentClass = addClass(constantPool, classDescription.name); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
763 |
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
|
764 |
int[] interfaces = new int[header.implementsAttr.size()]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
765 |
int i = 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
766 |
for (String intf : header.implementsAttr) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
767 |
interfaces[i++] = addClass(constantPool, intf); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
768 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
769 |
AccessFlags flags = new AccessFlags(header.flags); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
770 |
Map<String, Attribute> attributesMap = new HashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
771 |
addAttributes(header, constantPool, attributesMap); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
772 |
Attributes attributes = new Attributes(attributesMap); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
773 |
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
|
774 |
ClassFile classFile = new ClassFile(0xCAFEBABE, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
775 |
Target.DEFAULT.minorVersion, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
776 |
Target.DEFAULT.majorVersion, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
777 |
cp, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
778 |
flags, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
779 |
currentClass, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
780 |
superclass, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
781 |
interfaces, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
782 |
fields.toArray(new Field[0]), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
783 |
methods.toArray(new Method[0]), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
784 |
attributes); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
785 |
|
51832
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
786 |
Path outputClassFile = Paths.get(ctSymLocation, version); |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
787 |
|
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
788 |
if (module != null) { |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
789 |
outputClassFile = outputClassFile.resolve(module); |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
790 |
} |
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
791 |
|
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
792 |
outputClassFile = outputClassFile.resolve(classDescription.name + EXTENSION); |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
793 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
794 |
Files.createDirectories(outputClassFile.getParent()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
795 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
796 |
try (OutputStream out = Files.newOutputStream(outputClassFile)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
797 |
ClassWriter w = new ClassWriter(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
798 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
799 |
w.write(classFile, out); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
800 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
801 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
802 |
|
47703 | 803 |
private void addAttributes(ModuleDescription md, |
804 |
ModuleHeaderDescription header, |
|
805 |
List<CPInfo> cp, |
|
806 |
Map<String, Attribute> attributes) { |
|
807 |
addGenericAttributes(header, cp, attributes); |
|
808 |
if (header.moduleResolution != null) { |
|
809 |
int attrIdx = addString(cp, Attribute.ModuleResolution); |
|
810 |
final ModuleResolution_attribute resIdx = |
|
811 |
new ModuleResolution_attribute(attrIdx, |
|
812 |
header.moduleResolution); |
|
813 |
attributes.put(Attribute.ModuleResolution, resIdx); |
|
814 |
} |
|
815 |
if (header.moduleTarget != null) { |
|
816 |
int attrIdx = addString(cp, Attribute.ModuleTarget); |
|
817 |
int targetIdx = addString(cp, header.moduleTarget); |
|
818 |
attributes.put(Attribute.ModuleTarget, |
|
819 |
new ModuleTarget_attribute(attrIdx, targetIdx)); |
|
820 |
} |
|
821 |
int attrIdx = addString(cp, Attribute.Module); |
|
822 |
attributes.put(Attribute.Module, |
|
823 |
new Module_attribute(attrIdx, |
|
824 |
addModuleName(cp, md.name), |
|
825 |
0, |
|
826 |
0, |
|
827 |
header.requires |
|
828 |
.stream() |
|
829 |
.map(r -> createRequiresEntry(cp, r)) |
|
830 |
.collect(Collectors.toList()) |
|
831 |
.toArray(new RequiresEntry[0]), |
|
832 |
header.exports |
|
833 |
.stream() |
|
834 |
.map(e -> createExportsEntry(cp, e)) |
|
835 |
.collect(Collectors.toList()) |
|
836 |
.toArray(new ExportsEntry[0]), |
|
837 |
header.opens |
|
838 |
.stream() |
|
839 |
.map(e -> createOpensEntry(cp, e)) |
|
840 |
.collect(Collectors.toList()) |
|
841 |
.toArray(new OpensEntry[0]), |
|
842 |
header.uses |
|
843 |
.stream() |
|
844 |
.mapToInt(u -> addClassName(cp, u)) |
|
845 |
.toArray(), |
|
846 |
header.provides |
|
847 |
.stream() |
|
848 |
.map(p -> createProvidesEntry(cp, p)) |
|
849 |
.collect(Collectors.toList()) |
|
850 |
.toArray(new ProvidesEntry[0]))); |
|
851 |
addInnerClassesAttribute(header, cp, attributes); |
|
852 |
} |
|
853 |
||
854 |
private static RequiresEntry createRequiresEntry(List<CPInfo> cp, |
|
855 |
RequiresDescription r) { |
|
856 |
final int idx = addModuleName(cp, r.moduleName); |
|
857 |
return new RequiresEntry(idx, |
|
858 |
r.flags, |
|
859 |
r.version != null |
|
860 |
? addInt(cp, r.version) |
|
861 |
: 0); |
|
862 |
} |
|
863 |
||
864 |
private static ExportsEntry createExportsEntry(List<CPInfo> cp, |
|
865 |
String e) { |
|
866 |
return new ExportsEntry(addPackageName(cp, e), 0, new int[0]); |
|
867 |
} |
|
868 |
||
869 |
private static OpensEntry createOpensEntry(List<CPInfo> cp, String e) { |
|
870 |
return new OpensEntry(addPackageName(cp, e), 0, new int[0]); |
|
871 |
} |
|
872 |
||
873 |
private static ProvidesEntry createProvidesEntry(List<CPInfo> cp, |
|
874 |
ModuleHeaderDescription.ProvidesDescription p) { |
|
875 |
final int idx = addClassName(cp, p.interfaceName); |
|
876 |
return new ProvidesEntry(idx, p.implNames |
|
877 |
.stream() |
|
878 |
.mapToInt(i -> addClassName(cp, i)) |
|
879 |
.toArray()); |
|
880 |
} |
|
881 |
||
882 |
private void addAttributes(ClassHeaderDescription header, |
|
883 |
List<CPInfo> constantPool, Map<String, Attribute> attributes) { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
884 |
addGenericAttributes(header, constantPool, attributes); |
51799 | 885 |
if (header.nestHost != null) { |
886 |
int attributeString = addString(constantPool, Attribute.NestHost); |
|
887 |
int nestHost = addClass(constantPool, header.nestHost); |
|
888 |
attributes.put(Attribute.NestHost, |
|
889 |
new NestHost_attribute(attributeString, nestHost)); |
|
890 |
} |
|
891 |
if (header.nestMembers != null && !header.nestMembers.isEmpty()) { |
|
892 |
int attributeString = addString(constantPool, Attribute.NestMembers); |
|
893 |
int[] nestMembers = new int[header.nestMembers.size()]; |
|
894 |
int i = 0; |
|
895 |
for (String intf : header.nestMembers) { |
|
896 |
nestMembers[i++] = addClass(constantPool, intf); |
|
897 |
} |
|
898 |
attributes.put(Attribute.NestMembers, |
|
899 |
new NestMembers_attribute(attributeString, nestMembers)); |
|
900 |
} |
|
47703 | 901 |
addInnerClassesAttribute(header, constantPool, attributes); |
902 |
} |
|
903 |
||
904 |
private void addInnerClassesAttribute(HeaderDescription header, |
|
905 |
List<CPInfo> constantPool, Map<String, Attribute> attributes) { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
906 |
if (header.innerClasses != null && !header.innerClasses.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
907 |
Info[] innerClasses = new Info[header.innerClasses.size()]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
908 |
int i = 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
909 |
for (InnerClassInfo info : header.innerClasses) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
910 |
innerClasses[i++] = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
911 |
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
|
912 |
info.outerClass == null ? 0 : addClass(constantPool, info.outerClass), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
913 |
info.innerClassName == null ? 0 : addString(constantPool, info.innerClassName), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
914 |
new AccessFlags(info.innerClassFlags)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
915 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
916 |
int attributeString = addString(constantPool, Attribute.InnerClasses); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
917 |
attributes.put(Attribute.InnerClasses, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
918 |
new InnerClasses_attribute(attributeString, innerClasses)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
919 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
920 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
921 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
922 |
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
|
923 |
addGenericAttributes(desc, constantPool, attributes); |
50027 | 924 |
if (desc.thrownTypes != null) { |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
925 |
int[] exceptions = new int[desc.thrownTypes.size()]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
926 |
int i = 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
927 |
for (String exc : desc.thrownTypes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
928 |
exceptions[i++] = addClass(constantPool, exc); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
929 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
930 |
int attributeString = addString(constantPool, Attribute.Exceptions); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
931 |
attributes.put(Attribute.Exceptions, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
932 |
new Exceptions_attribute(attributeString, exceptions)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
933 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
934 |
if (desc.annotationDefaultValue != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
935 |
int attributeString = addString(constantPool, Attribute.AnnotationDefault); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
936 |
element_value attributeValue = createAttributeValue(constantPool, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
937 |
desc.annotationDefaultValue); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
938 |
attributes.put(Attribute.AnnotationDefault, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
939 |
new AnnotationDefault_attribute(attributeString, attributeValue)); |
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 |
if (desc.classParameterAnnotations != null && !desc.classParameterAnnotations.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
942 |
int attributeString = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
943 |
addString(constantPool, Attribute.RuntimeInvisibleParameterAnnotations); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
944 |
Annotation[][] annotations = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
945 |
createParameterAnnotations(constantPool, desc.classParameterAnnotations); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
946 |
attributes.put(Attribute.RuntimeInvisibleParameterAnnotations, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
947 |
new RuntimeInvisibleParameterAnnotations_attribute(attributeString, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
948 |
annotations)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
949 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
950 |
if (desc.runtimeParameterAnnotations != null && !desc.runtimeParameterAnnotations.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
951 |
int attributeString = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
952 |
addString(constantPool, Attribute.RuntimeVisibleParameterAnnotations); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
953 |
Annotation[][] annotations = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
954 |
createParameterAnnotations(constantPool, desc.runtimeParameterAnnotations); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
955 |
attributes.put(Attribute.RuntimeVisibleParameterAnnotations, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
956 |
new RuntimeVisibleParameterAnnotations_attribute(attributeString, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
957 |
annotations)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
958 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
959 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
960 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
961 |
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
|
962 |
addGenericAttributes(desc, constantPool, attributes); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
963 |
if (desc.constantValue != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
964 |
Pair<Integer, Character> constantPoolEntry = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
965 |
addConstant(constantPool, desc.constantValue, false); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
966 |
Assert.checkNonNull(constantPoolEntry); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
967 |
int constantValueString = addString(constantPool, Attribute.ConstantValue); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
968 |
attributes.put(Attribute.ConstantValue, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
969 |
new ConstantValue_attribute(constantValueString, constantPoolEntry.fst)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
970 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
971 |
} |
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 |
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
|
974 |
if (desc.deprecated) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
975 |
int attributeString = addString(constantPool, Attribute.Deprecated); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
976 |
attributes.put(Attribute.Deprecated, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
977 |
new Deprecated_attribute(attributeString)); |
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 |
if (desc.signature != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
980 |
int attributeString = addString(constantPool, Attribute.Signature); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
981 |
int signatureString = addString(constantPool, desc.signature); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
982 |
attributes.put(Attribute.Signature, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
983 |
new Signature_attribute(attributeString, signatureString)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
984 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
985 |
if (desc.classAnnotations != null && !desc.classAnnotations.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
986 |
int attributeString = addString(constantPool, Attribute.RuntimeInvisibleAnnotations); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
987 |
Annotation[] annotations = createAnnotations(constantPool, desc.classAnnotations); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
988 |
attributes.put(Attribute.RuntimeInvisibleAnnotations, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
989 |
new RuntimeInvisibleAnnotations_attribute(attributeString, annotations)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
990 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
991 |
if (desc.runtimeAnnotations != null && !desc.runtimeAnnotations.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
992 |
int attributeString = addString(constantPool, Attribute.RuntimeVisibleAnnotations); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
993 |
Annotation[] annotations = createAnnotations(constantPool, desc.runtimeAnnotations); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
994 |
attributes.put(Attribute.RuntimeVisibleAnnotations, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
995 |
new RuntimeVisibleAnnotations_attribute(attributeString, annotations)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
996 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
997 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
998 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
999 |
private Annotation[] createAnnotations(List<CPInfo> constantPool, List<AnnotationDescription> desc) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1000 |
Annotation[] result = new Annotation[desc.size()]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1001 |
int i = 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1002 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1003 |
for (AnnotationDescription ad : desc) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1004 |
result[i++] = createAnnotation(constantPool, ad); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1005 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1006 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1007 |
return result; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1008 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1009 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1010 |
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
|
1011 |
Annotation[][] result = new Annotation[desc.size()][]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1012 |
int i = 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1013 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1014 |
for (List<AnnotationDescription> paramAnnos : desc) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1015 |
result[i++] = createAnnotations(constantPool, paramAnnos); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1016 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1017 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1018 |
return result; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1019 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1020 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1021 |
private Annotation createAnnotation(List<CPInfo> constantPool, AnnotationDescription desc) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1022 |
return new Annotation(null, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1023 |
addString(constantPool, desc.annotationType), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1024 |
createElementPairs(constantPool, desc.values)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1025 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1026 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1027 |
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
|
1028 |
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
|
1029 |
int i = 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1030 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1031 |
for (Entry<String, Object> e : annotationAttributes.entrySet()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1032 |
int elementNameString = addString(constantPool, e.getKey()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1033 |
element_value value = createAttributeValue(constantPool, e.getValue()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1034 |
pairs[i++] = new element_value_pair(elementNameString, value); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1035 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1036 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1037 |
return pairs; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1038 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1039 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1040 |
private element_value createAttributeValue(List<CPInfo> constantPool, Object value) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1041 |
Pair<Integer, Character> constantPoolEntry = addConstant(constantPool, value, true); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1042 |
if (constantPoolEntry != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1043 |
return new Primitive_element_value(constantPoolEntry.fst, constantPoolEntry.snd); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1044 |
} else if (value instanceof EnumConstant) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1045 |
EnumConstant ec = (EnumConstant) value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1046 |
return new Enum_element_value(addString(constantPool, ec.type), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1047 |
addString(constantPool, ec.constant), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1048 |
'e'); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1049 |
} else if (value instanceof ClassConstant) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1050 |
ClassConstant cc = (ClassConstant) value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1051 |
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
|
1052 |
} else if (value instanceof AnnotationDescription) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1053 |
Annotation annotation = createAnnotation(constantPool, ((AnnotationDescription) value)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1054 |
return new Annotation_element_value(annotation, '@'); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1055 |
} else if (value instanceof Collection) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1056 |
@SuppressWarnings("unchecked") |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1057 |
Collection<Object> array = (Collection<Object>) value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1058 |
element_value[] values = new element_value[array.size()]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1059 |
int i = 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1060 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1061 |
for (Object elem : array) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1062 |
values[i++] = createAttributeValue(constantPool, elem); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1063 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1064 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1065 |
return new Array_element_value(values, '['); |
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 |
throw new IllegalStateException(value.getClass().getName()); |
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 |
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
|
1071 |
if (value instanceof Boolean) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1072 |
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
|
1073 |
} else if (value instanceof Byte) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1074 |
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
|
1075 |
} else if (value instanceof Character) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1076 |
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
|
1077 |
} else if (value instanceof Short) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1078 |
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
|
1079 |
} else if (value instanceof Integer) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1080 |
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
|
1081 |
} else if (value instanceof Long) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1082 |
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
|
1083 |
} else if (value instanceof Float) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1084 |
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
|
1085 |
} else if (value instanceof Double) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1086 |
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
|
1087 |
} else if (value instanceof String) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1088 |
int stringIndex = addString(constantPool, (String) value); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1089 |
if (annotation) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1090 |
return Pair.of(stringIndex, 's'); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1091 |
} else { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1092 |
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
|
1093 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1094 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1095 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1096 |
return null; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1097 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1098 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1099 |
private static int addString(List<CPInfo> constantPool, String string) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1100 |
Assert.checkNonNull(string); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1101 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1102 |
int i = 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1103 |
for (CPInfo info : constantPool) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1104 |
if (info instanceof CONSTANT_Utf8_info) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1105 |
if (((CONSTANT_Utf8_info) info).value.equals(string)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1106 |
return i; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1107 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1108 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1109 |
i++; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1110 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1111 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1112 |
return addToCP(constantPool, new CONSTANT_Utf8_info(string)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1113 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1114 |
|
47703 | 1115 |
private static int addInt(List<CPInfo> constantPool, int value) { |
1116 |
int i = 0; |
|
1117 |
for (CPInfo info : constantPool) { |
|
1118 |
if (info instanceof CONSTANT_Integer_info) { |
|
1119 |
if (((CONSTANT_Integer_info) info).value == value) { |
|
1120 |
return i; |
|
1121 |
} |
|
1122 |
} |
|
1123 |
i++; |
|
1124 |
} |
|
1125 |
||
1126 |
return addToCP(constantPool, new CONSTANT_Integer_info(value)); |
|
1127 |
} |
|
1128 |
||
1129 |
private static int addModuleName(List<CPInfo> constantPool, String moduleName) { |
|
1130 |
int nameIdx = addString(constantPool, moduleName); |
|
1131 |
int i = 0; |
|
1132 |
for (CPInfo info : constantPool) { |
|
1133 |
if (info instanceof CONSTANT_Module_info) { |
|
1134 |
if (((CONSTANT_Module_info) info).name_index == nameIdx) { |
|
1135 |
return i; |
|
1136 |
} |
|
1137 |
} |
|
1138 |
i++; |
|
1139 |
} |
|
1140 |
||
1141 |
return addToCP(constantPool, new CONSTANT_Module_info(null, nameIdx)); |
|
1142 |
} |
|
1143 |
||
1144 |
private static int addPackageName(List<CPInfo> constantPool, String packageName) { |
|
1145 |
int nameIdx = addString(constantPool, packageName); |
|
1146 |
int i = 0; |
|
1147 |
for (CPInfo info : constantPool) { |
|
1148 |
if (info instanceof CONSTANT_Package_info) { |
|
1149 |
if (((CONSTANT_Package_info) info).name_index == nameIdx) { |
|
1150 |
return i; |
|
1151 |
} |
|
1152 |
} |
|
1153 |
i++; |
|
1154 |
} |
|
1155 |
||
1156 |
return addToCP(constantPool, new CONSTANT_Package_info(null, nameIdx)); |
|
1157 |
} |
|
1158 |
||
1159 |
private static int addClassName(List<CPInfo> constantPool, String className) { |
|
1160 |
int nameIdx = addString(constantPool, className); |
|
1161 |
int i = 0; |
|
1162 |
for (CPInfo info : constantPool) { |
|
1163 |
if (info instanceof CONSTANT_Class_info) { |
|
1164 |
if (((CONSTANT_Class_info) info).name_index == nameIdx) { |
|
1165 |
return i; |
|
1166 |
} |
|
1167 |
} |
|
1168 |
i++; |
|
1169 |
} |
|
1170 |
||
1171 |
return addToCP(constantPool, new CONSTANT_Class_info(null, nameIdx)); |
|
1172 |
} |
|
1173 |
||
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1174 |
private static int addToCP(List<CPInfo> constantPool, CPInfo entry) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1175 |
int result = constantPool.size(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1176 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1177 |
constantPool.add(entry); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1178 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1179 |
if (entry.size() > 1) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1180 |
constantPool.add(null); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1181 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1182 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1183 |
return result; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1184 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1185 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1186 |
private static int addClass(List<CPInfo> constantPool, String className) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1187 |
int classNameIndex = addString(constantPool, className); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1188 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1189 |
int i = 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1190 |
for (CPInfo info : constantPool) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1191 |
if (info instanceof CONSTANT_Class_info) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1192 |
if (((CONSTANT_Class_info) info).name_index == classNameIndex) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1193 |
return i; |
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 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1196 |
i++; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1197 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1198 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1199 |
return addToCP(constantPool, new CONSTANT_Class_info(null, classNameIndex)); |
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 |
//</editor-fold> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1202 |
//</editor-fold> |
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 |
//<editor-fold defaultstate="collapsed" desc="Create Symbol Description"> |
47703 | 1205 |
public void createBaseLine(List<VersionDescription> versions, |
1206 |
ExcludeIncludeList excludesIncludes, |
|
1207 |
Path descDest, |
|
1208 |
String[] args) throws IOException { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1209 |
ClassList classes = new ClassList(); |
47703 | 1210 |
Map<String, ModuleDescription> modules = new HashMap<>(); |
31506
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 |
for (VersionDescription desc : versions) { |
50027 | 1213 |
List<byte[]> classFileData = new ArrayList<>(); |
1214 |
||
47703 | 1215 |
try (BufferedReader descIn = |
1216 |
Files.newBufferedReader(Paths.get(desc.classes))) { |
|
50027 | 1217 |
String line; |
1218 |
while ((line = descIn.readLine()) != null) { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1219 |
ByteArrayOutputStream data = new ByteArrayOutputStream(); |
50027 | 1220 |
for (int i = 0; i < line.length(); i += 2) { |
1221 |
String hex = line.substring(i, i + 2); |
|
47703 | 1222 |
data.write(Integer.parseInt(hex, 16)); |
1223 |
} |
|
50027 | 1224 |
classFileData.add(data.toByteArray()); |
47703 | 1225 |
} |
50027 | 1226 |
} catch (IOException ex) { |
1227 |
throw new IllegalStateException(ex); |
|
47703 | 1228 |
} |
1229 |
||
50027 | 1230 |
loadVersionClasses(classes, modules, classFileData, excludesIncludes, desc.version); |
1231 |
} |
|
1232 |
||
1233 |
List<PlatformInput> platforms = |
|
1234 |
versions.stream() |
|
51799 | 1235 |
.map(desc -> new PlatformInput(null, |
1236 |
desc.version, |
|
50027 | 1237 |
desc.primaryBaseline, |
1238 |
null)) |
|
1239 |
.collect(Collectors.toList()); |
|
1240 |
||
1241 |
dumpDescriptions(classes, modules, platforms, descDest.resolve("symbols"), args); |
|
1242 |
} |
|
1243 |
//where: |
|
1244 |
private static final String DO_NO_MODIFY = |
|
1245 |
"#\n" + |
|
1246 |
"# Copyright (c) {YEAR}, Oracle and/or its affiliates. All rights reserved.\n" + |
|
1247 |
"# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.\n" + |
|
1248 |
"#\n" + |
|
1249 |
"# This code is free software; you can redistribute it and/or modify it\n" + |
|
1250 |
"# under the terms of the GNU General Public License version 2 only, as\n" + |
|
1251 |
"# published by the Free Software Foundation. Oracle designates this\n" + |
|
1252 |
"# particular file as subject to the \"Classpath\" exception as provided\n" + |
|
1253 |
"# by Oracle in the LICENSE file that accompanied this code.\n" + |
|
1254 |
"#\n" + |
|
1255 |
"# This code is distributed in the hope that it will be useful, but WITHOUT\n" + |
|
1256 |
"# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n" + |
|
1257 |
"# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License\n" + |
|
1258 |
"# version 2 for more details (a copy is included in the LICENSE file that\n" + |
|
1259 |
"# accompanied this code).\n" + |
|
1260 |
"#\n" + |
|
1261 |
"# You should have received a copy of the GNU General Public License version\n" + |
|
1262 |
"# 2 along with this work; if not, write to the Free Software Foundation,\n" + |
|
1263 |
"# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.\n" + |
|
1264 |
"#\n" + |
|
1265 |
"# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA\n" + |
|
1266 |
"# or visit www.oracle.com if you need additional information or have any\n" + |
|
1267 |
"# questions.\n" + |
|
1268 |
"#\n" + |
|
1269 |
"# ##########################################################\n" + |
|
1270 |
"# ### THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. ###\n" + |
|
1271 |
"# ##########################################################\n" + |
|
1272 |
"#\n"; |
|
1273 |
||
1274 |
private void loadVersionClasses(ClassList classes, |
|
1275 |
Map<String, ModuleDescription> modules, |
|
1276 |
Iterable<byte[]> classData, |
|
1277 |
ExcludeIncludeList excludesIncludes, |
|
1278 |
String version) { |
|
1279 |
Map<String, ModuleDescription> currentVersionModules = |
|
1280 |
new HashMap<>(); |
|
1281 |
||
1282 |
for (byte[] classFileData : classData) { |
|
1283 |
try (InputStream in = new ByteArrayInputStream(classFileData)) { |
|
1284 |
inspectModuleInfoClassFile(in, |
|
1285 |
currentVersionModules, version); |
|
1286 |
} catch (IOException | ConstantPoolException ex) { |
|
1287 |
throw new IllegalStateException(ex); |
|
47703 | 1288 |
} |
50027 | 1289 |
} |
1290 |
||
1291 |
ExcludeIncludeList currentEIList = excludesIncludes; |
|
1292 |
||
1293 |
if (!currentVersionModules.isEmpty()) { |
|
1294 |
Set<String> includes = new HashSet<>(); |
|
1295 |
||
1296 |
for (ModuleDescription md : currentVersionModules.values()) { |
|
1297 |
md.header.get(0).exports.stream().map(e -> e + '/') |
|
1298 |
.forEach(includes::add); |
|
1299 |
} |
|
1300 |
||
1301 |
currentEIList = new ExcludeIncludeList(includes, |
|
1302 |
Collections.emptySet()); |
|
1303 |
} |
|
1304 |
||
1305 |
ClassList currentVersionClasses = new ClassList(); |
|
1306 |
||
1307 |
for (byte[] classFileData : classData) { |
|
1308 |
try (InputStream in = new ByteArrayInputStream(classFileData)) { |
|
1309 |
inspectClassFile(in, currentVersionClasses, |
|
1310 |
currentEIList, version); |
|
1311 |
} catch (IOException | ConstantPoolException ex) { |
|
1312 |
throw new IllegalStateException(ex); |
|
1313 |
} |
|
1314 |
} |
|
1315 |
||
1316 |
ModuleDescription unsupported = |
|
1317 |
currentVersionModules.get("jdk.unsupported"); |
|
1318 |
||
1319 |
if (unsupported != null) { |
|
1320 |
for (ClassDescription cd : currentVersionClasses.classes) { |
|
1321 |
if (unsupported.header |
|
1322 |
.get(0) |
|
1323 |
.exports |
|
1324 |
.contains(cd.packge().replace('.', '/'))) { |
|
1325 |
ClassHeaderDescription ch = cd.header.get(0); |
|
1326 |
if (ch.classAnnotations == null) { |
|
1327 |
ch.classAnnotations = new ArrayList<>(); |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1328 |
} |
50027 | 1329 |
AnnotationDescription ad; |
1330 |
ad = new AnnotationDescription(PROPERITARY_ANNOTATION, |
|
1331 |
Collections.emptyMap()); |
|
1332 |
ch.classAnnotations.add(ad); |
|
47703 | 1333 |
} |
1334 |
} |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1335 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1336 |
|
50027 | 1337 |
Set<String> includedClasses = new HashSet<>(); |
1338 |
boolean modified; |
|
1339 |
||
1340 |
do { |
|
1341 |
modified = false; |
|
1342 |
||
1343 |
for (ClassDescription clazz : currentVersionClasses) { |
|
1344 |
ClassHeaderDescription header = clazz.header.get(0); |
|
1345 |
||
1346 |
if (includeEffectiveAccess(currentVersionClasses, clazz)) { |
|
1347 |
modified |= include(includedClasses, currentVersionClasses, clazz.name); |
|
1348 |
} |
|
1349 |
||
1350 |
if (includedClasses.contains(clazz.name)) { |
|
1351 |
modified |= include(includedClasses, currentVersionClasses, header.extendsAttr); |
|
1352 |
for (String i : header.implementsAttr) { |
|
1353 |
modified |= include(includedClasses, currentVersionClasses, i); |
|
1354 |
} |
|
1355 |
||
1356 |
modified |= includeOutputType(Collections.singleton(header), |
|
1357 |
h -> "", |
|
1358 |
includedClasses, |
|
1359 |
currentVersionClasses); |
|
1360 |
modified |= includeOutputType(clazz.fields, |
|
1361 |
f -> f.descriptor, |
|
1362 |
includedClasses, |
|
1363 |
currentVersionClasses); |
|
1364 |
modified |= includeOutputType(clazz.methods, |
|
1365 |
m -> m.descriptor, |
|
1366 |
includedClasses, |
|
1367 |
currentVersionClasses); |
|
1368 |
} |
|
1369 |
} |
|
1370 |
} while (modified); |
|
1371 |
||
1372 |
for (ClassDescription clazz : currentVersionClasses) { |
|
1373 |
if (!includedClasses.contains(clazz.name)) { |
|
1374 |
continue; |
|
1375 |
} |
|
1376 |
||
1377 |
ClassHeaderDescription header = clazz.header.get(0); |
|
1378 |
||
51799 | 1379 |
if (header.nestMembers != null) { |
1380 |
Iterator<String> nestMemberIt = header.nestMembers.iterator(); |
|
1381 |
||
1382 |
while(nestMemberIt.hasNext()) { |
|
1383 |
String member = nestMemberIt.next(); |
|
1384 |
if (!includedClasses.contains(member)) |
|
1385 |
nestMemberIt.remove(); |
|
1386 |
} |
|
1387 |
} |
|
1388 |
||
50027 | 1389 |
if (header.innerClasses != null) { |
1390 |
Iterator<InnerClassInfo> innerClassIt = header.innerClasses.iterator(); |
|
1391 |
||
1392 |
while(innerClassIt.hasNext()) { |
|
1393 |
InnerClassInfo ici = innerClassIt.next(); |
|
1394 |
if (!includedClasses.contains(ici.innerClass)) |
|
1395 |
innerClassIt.remove(); |
|
1396 |
} |
|
1397 |
} |
|
1398 |
||
1399 |
ClassDescription existing = classes.find(clazz.name, true); |
|
1400 |
||
1401 |
if (existing != null) { |
|
1402 |
addClassHeader(existing, header, version); |
|
1403 |
for (MethodDescription currentMethod : clazz.methods) { |
|
1404 |
addMethod(existing, currentMethod, version); |
|
1405 |
} |
|
1406 |
for (FieldDescription currentField : clazz.fields) { |
|
1407 |
addField(existing, currentField, version); |
|
1408 |
} |
|
1409 |
} else { |
|
1410 |
classes.add(clazz); |
|
1411 |
} |
|
1412 |
} |
|
1413 |
||
1414 |
for (ModuleDescription module : currentVersionModules.values()) { |
|
1415 |
ModuleHeaderDescription header = module.header.get(0); |
|
1416 |
||
1417 |
if (header.innerClasses != null) { |
|
1418 |
Iterator<InnerClassInfo> innerClassIt = |
|
1419 |
header.innerClasses.iterator(); |
|
1420 |
||
1421 |
while(innerClassIt.hasNext()) { |
|
1422 |
InnerClassInfo ici = innerClassIt.next(); |
|
1423 |
if (!includedClasses.contains(ici.innerClass)) |
|
1424 |
innerClassIt.remove(); |
|
1425 |
} |
|
1426 |
} |
|
1427 |
||
1428 |
ModuleDescription existing = modules.get(module.name); |
|
1429 |
||
1430 |
if (existing != null) { |
|
1431 |
addModuleHeader(existing, header, version); |
|
1432 |
} else { |
|
1433 |
modules.put(module.name, module); |
|
1434 |
} |
|
1435 |
} |
|
1436 |
} |
|
1437 |
//where: |
|
1438 |
private static final String PROPERITARY_ANNOTATION = |
|
1439 |
"Lsun/Proprietary+Annotation;"; |
|
1440 |
||
1441 |
private void dumpDescriptions(ClassList classes, |
|
1442 |
Map<String, ModuleDescription> modules, |
|
1443 |
List<PlatformInput> versions, |
|
1444 |
Path ctDescriptionFile, |
|
1445 |
String[] args) throws IOException { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1446 |
classes.sort(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1447 |
|
47703 | 1448 |
Map<String, String> package2Modules = new HashMap<>(); |
1449 |
||
51799 | 1450 |
versions.stream() |
1451 |
.filter(v -> "9".compareTo(v.version) <= 0) |
|
1452 |
.sorted((v1, v2) -> v1.version.compareTo(v2.version)) |
|
1453 |
.forEach(v -> { |
|
1454 |
for (ModuleDescription md : modules.values()) { |
|
1455 |
md.header |
|
1456 |
.stream() |
|
1457 |
.filter(h -> h.versions.contains(v.version)) |
|
1458 |
.flatMap(h -> h.exports.stream()) |
|
1459 |
.map(p -> p.replace('/', '.')) |
|
1460 |
.forEach(p -> package2Modules.putIfAbsent(p, md.name)); |
|
1461 |
} |
|
1462 |
}); |
|
47703 | 1463 |
|
1464 |
package2Modules.put("java.awt.dnd.peer", "java.desktop"); |
|
1465 |
package2Modules.put("java.awt.peer", "java.desktop"); |
|
1466 |
package2Modules.put("jdk", "java.base"); |
|
1467 |
||
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1468 |
Map<String, List<ClassDescription>> module2Classes = new HashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1469 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1470 |
for (ClassDescription clazz : classes) { |
47703 | 1471 |
String pack = clazz.packge(); |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1472 |
String module = package2Modules.get(pack); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1473 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1474 |
if (module == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1475 |
module = "java.base"; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1476 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1477 |
OUTER: while (!pack.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1478 |
for (Entry<String, String> p2M : package2Modules.entrySet()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1479 |
if (p2M.getKey().startsWith(pack)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1480 |
module = p2M.getValue(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1481 |
break OUTER; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1482 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1483 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1484 |
int dot = pack.lastIndexOf('.'); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1485 |
if (dot == (-1)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1486 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1487 |
pack = pack.substring(0, dot); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1488 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1489 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1490 |
module2Classes.computeIfAbsent(module, m -> new ArrayList<>()) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1491 |
.add(clazz); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1492 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1493 |
|
47703 | 1494 |
modules.keySet() |
1495 |
.stream() |
|
1496 |
.filter(m -> !module2Classes.containsKey(m)) |
|
1497 |
.forEach(m -> module2Classes.put(m, Collections.emptyList())); |
|
1498 |
||
50027 | 1499 |
Files.createDirectories(ctDescriptionFile.getParent()); |
1500 |
||
1501 |
int year = Calendar.getInstance(TimeZone.getTimeZone("UTF"), Locale.ROOT) |
|
1502 |
.get(Calendar.YEAR); |
|
1503 |
||
1504 |
try (Writer symbolsOut = Files.newBufferedWriter(ctDescriptionFile)) { |
|
1505 |
Map<PlatformInput, List<String>> outputFiles = new LinkedHashMap<>(); |
|
1506 |
||
1507 |
for (PlatformInput desc : versions) { |
|
1508 |
List<String> files = desc.files; |
|
1509 |
||
1510 |
if (files == null) { |
|
1511 |
files = new ArrayList<>(); |
|
1512 |
for (Entry<String, List<ClassDescription>> e : module2Classes.entrySet()) { |
|
1513 |
StringWriter data = new StringWriter(); |
|
1514 |
ModuleDescription module = modules.get(e.getKey()); |
|
1515 |
||
1516 |
module.write(data, desc.basePlatform, desc.version); |
|
1517 |
||
1518 |
for (ClassDescription clazz : e.getValue()) { |
|
1519 |
clazz.write(data, desc.basePlatform, desc.version); |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1520 |
} |
47703 | 1521 |
|
50027 | 1522 |
String fileName = e.getKey() + "-" + desc.version + ".sym.txt"; |
1523 |
Path f = ctDescriptionFile.getParent().resolve(fileName); |
|
1524 |
||
1525 |
String dataString = data.toString(); |
|
1526 |
||
1527 |
if (!dataString.isEmpty()) { |
|
1528 |
try (Writer out = Files.newBufferedWriter(f)) { |
|
1529 |
out.append(DO_NO_MODIFY.replace("{YEAR}", String.valueOf(year))); |
|
1530 |
out.write(dataString); |
|
1531 |
} |
|
1532 |
files.add(f.getFileName().toString()); |
|
1533 |
} |
|
31506
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 |
} |
50027 | 1536 |
|
1537 |
outputFiles.put(desc, files); |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1538 |
} |
50027 | 1539 |
symbolsOut.append(DO_NO_MODIFY.replace("{YEAR}", "2015, " + year)); |
47703 | 1540 |
symbolsOut.append("#command used to generate this file:\n"); |
1541 |
symbolsOut.append("#") |
|
1542 |
.append(CreateSymbols.class.getName()) |
|
1543 |
.append(" ") |
|
50027 | 1544 |
.append(Arrays.stream(args) |
47703 | 1545 |
.collect(Collectors.joining(" "))) |
1546 |
.append("\n"); |
|
1547 |
symbolsOut.append("#\n"); |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1548 |
symbolsOut.append("generate platforms ") |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1549 |
.append(versions.stream() |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1550 |
.map(v -> v.version) |
47703 | 1551 |
.sorted() |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1552 |
.collect(Collectors.joining(":"))) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1553 |
.append("\n"); |
50027 | 1554 |
for (Entry<PlatformInput, List<String>> versionFileEntry : outputFiles.entrySet()) { |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1555 |
symbolsOut.append("platform version ") |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1556 |
.append(versionFileEntry.getKey().version); |
50027 | 1557 |
if (versionFileEntry.getKey().basePlatform != null) { |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1558 |
symbolsOut.append(" base ") |
50027 | 1559 |
.append(versionFileEntry.getKey().basePlatform); |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1560 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1561 |
symbolsOut.append(" files ") |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1562 |
.append(versionFileEntry.getValue() |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1563 |
.stream() |
50027 | 1564 |
.map(p -> p) |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1565 |
.sorted() |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1566 |
.collect(Collectors.joining(":"))) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1567 |
.append("\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1568 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1569 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1570 |
} |
50027 | 1571 |
|
1572 |
public void createIncrementalBaseLine(String ctDescriptionFile, |
|
1573 |
String excludeFile, |
|
1574 |
String[] args) throws IOException { |
|
1575 |
String specVersion = System.getProperty("java.specification.version"); |
|
1576 |
String currentVersion = |
|
1577 |
Integer.toString(Integer.parseInt(specVersion), Character.MAX_RADIX); |
|
1578 |
currentVersion = currentVersion.toUpperCase(Locale.ROOT); |
|
1579 |
Path ctDescriptionPath = Paths.get(ctDescriptionFile).toAbsolutePath(); |
|
51799 | 1580 |
LoadDescriptions data = load(null, ctDescriptionPath, currentVersion); |
50027 | 1581 |
|
1582 |
ClassList classes = data.classes; |
|
1583 |
Map<String, ModuleDescription> modules = data.modules; |
|
1584 |
List<PlatformInput> versions = data.versions; |
|
1585 |
||
1586 |
ExcludeIncludeList excludeList = |
|
1587 |
ExcludeIncludeList.create(excludeFile); |
|
1588 |
||
1589 |
Iterable<byte[]> classBytes = dumpCurrentClasses(); |
|
1590 |
loadVersionClasses(classes, modules, classBytes, excludeList, currentVersion); |
|
1591 |
||
1592 |
String baseline; |
|
1593 |
||
1594 |
if (versions.isEmpty()) { |
|
1595 |
baseline = null; |
|
1596 |
} else { |
|
1597 |
baseline = versions.stream() |
|
1598 |
.sorted((v1, v2) -> v2.version.compareTo(v1.version)) |
|
1599 |
.findFirst() |
|
1600 |
.get() |
|
1601 |
.version; |
|
1602 |
} |
|
1603 |
||
51799 | 1604 |
versions.add(new PlatformInput(null, currentVersion, baseline, null)); |
50027 | 1605 |
dumpDescriptions(classes, modules, versions, ctDescriptionPath, args); |
1606 |
} |
|
1607 |
||
1608 |
private List<byte[]> dumpCurrentClasses() throws IOException { |
|
1609 |
JavacTool tool = JavacTool.create(); |
|
1610 |
Context ctx = new Context(); |
|
1611 |
String version = System.getProperty("java.specification.version"); |
|
1612 |
JavacTask task = tool.getTask(null, null, null, |
|
1613 |
List.of("--release", version), |
|
1614 |
null, null, ctx); |
|
1615 |
task.getElements().getTypeElement("java.lang.Object"); |
|
1616 |
JavaFileManager fm = ctx.get(JavaFileManager.class); |
|
1617 |
||
1618 |
List<byte[]> data = new ArrayList<>(); |
|
1619 |
for (Location modLoc : LOCATIONS) { |
|
1620 |
for (Set<JavaFileManager.Location> module : |
|
1621 |
fm.listLocationsForModules(modLoc)) { |
|
1622 |
for (JavaFileManager.Location loc : module) { |
|
1623 |
Iterable<JavaFileObject> files = |
|
1624 |
fm.list(loc, |
|
1625 |
"", |
|
1626 |
EnumSet.of(Kind.CLASS), |
|
1627 |
true); |
|
1628 |
||
1629 |
for (JavaFileObject jfo : files) { |
|
1630 |
try (InputStream is = jfo.openInputStream(); |
|
1631 |
InputStream in = |
|
1632 |
new BufferedInputStream(is)) { |
|
1633 |
ByteArrayOutputStream baos = |
|
1634 |
new ByteArrayOutputStream(); |
|
1635 |
||
1636 |
in.transferTo(baos); |
|
1637 |
data.add(baos.toByteArray()); |
|
1638 |
} |
|
1639 |
} |
|
1640 |
} |
|
1641 |
} |
|
1642 |
} |
|
1643 |
||
1644 |
return data; |
|
1645 |
} |
|
47703 | 1646 |
//where: |
50027 | 1647 |
private static final List<StandardLocation> LOCATIONS = |
1648 |
List.of(StandardLocation.SYSTEM_MODULES, |
|
1649 |
StandardLocation.UPGRADE_MODULE_PATH); |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1650 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1651 |
//<editor-fold defaultstate="collapsed" desc="Class Reading"> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1652 |
//non-final for tests: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1653 |
public static String PROFILE_ANNOTATION = "Ljdk/Profile+Annotation;"; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1654 |
public static boolean ALLOW_NON_EXISTING_CLASSES = false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1655 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1656 |
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
|
1657 |
ClassFile cf = ClassFile.read(in); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1658 |
|
47703 | 1659 |
if (cf.access_flags.is(AccessFlags.ACC_MODULE)) { |
1660 |
return ; |
|
1661 |
} |
|
1662 |
||
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1663 |
if (!excludesIncludes.accepts(cf.getName())) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1664 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1665 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1666 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1667 |
ClassHeaderDescription headerDesc = new ClassHeaderDescription(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1668 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1669 |
headerDesc.flags = cf.access_flags.flags; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1670 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1671 |
if (cf.super_class != 0) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1672 |
headerDesc.extendsAttr = cf.getSuperclassName(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1673 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1674 |
List<String> interfaces = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1675 |
for (int i = 0; i < cf.interfaces.length; i++) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1676 |
interfaces.add(cf.getInterfaceName(i)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1677 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1678 |
headerDesc.implementsAttr = interfaces; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1679 |
for (Attribute attr : cf.attributes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1680 |
if (!readAttribute(cf, headerDesc, attr)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1681 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1682 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1683 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1684 |
ClassDescription clazzDesc = null; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1685 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1686 |
for (ClassDescription cd : classes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1687 |
if (cd.name.equals(cf.getName())) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1688 |
clazzDesc = cd; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1689 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1690 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1691 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1692 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1693 |
if (clazzDesc == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1694 |
clazzDesc = new ClassDescription(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1695 |
clazzDesc.name = cf.getName(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1696 |
classes.add(clazzDesc); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1697 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1698 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1699 |
addClassHeader(clazzDesc, headerDesc, version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1700 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1701 |
for (Method m : cf.methods) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1702 |
if (!include(m.access_flags.flags)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1703 |
continue; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1704 |
MethodDescription methDesc = new MethodDescription(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1705 |
methDesc.flags = m.access_flags.flags; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1706 |
methDesc.name = m.getName(cf.constant_pool); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1707 |
methDesc.descriptor = m.descriptor.getValue(cf.constant_pool); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1708 |
for (Attribute attr : m.attributes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1709 |
readAttribute(cf, methDesc, attr); |
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 |
addMethod(clazzDesc, methDesc, version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1712 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1713 |
for (Field f : cf.fields) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1714 |
if (!include(f.access_flags.flags)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1715 |
continue; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1716 |
FieldDescription fieldDesc = new FieldDescription(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1717 |
fieldDesc.flags = f.access_flags.flags; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1718 |
fieldDesc.name = f.getName(cf.constant_pool); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1719 |
fieldDesc.descriptor = f.descriptor.getValue(cf.constant_pool); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1720 |
for (Attribute attr : f.attributes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1721 |
readAttribute(cf, fieldDesc, attr); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1722 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1723 |
addField(clazzDesc, fieldDesc, version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1724 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1725 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1726 |
|
47703 | 1727 |
private void inspectModuleInfoClassFile(InputStream in, |
1728 |
Map<String, ModuleDescription> modules, |
|
1729 |
String version) throws IOException, ConstantPoolException { |
|
1730 |
ClassFile cf = ClassFile.read(in); |
|
1731 |
||
1732 |
if (!cf.access_flags.is(AccessFlags.ACC_MODULE)) { |
|
1733 |
return ; |
|
1734 |
} |
|
1735 |
||
1736 |
ModuleHeaderDescription headerDesc = new ModuleHeaderDescription(); |
|
1737 |
||
1738 |
headerDesc.versions = version; |
|
1739 |
headerDesc.flags = cf.access_flags.flags; |
|
1740 |
||
1741 |
for (Attribute attr : cf.attributes) { |
|
1742 |
if (!readAttribute(cf, headerDesc, attr)) |
|
1743 |
return ; |
|
1744 |
} |
|
1745 |
||
1746 |
String name = headerDesc.name; |
|
1747 |
||
1748 |
ModuleDescription moduleDesc = modules.get(name); |
|
1749 |
||
1750 |
if (moduleDesc == null) { |
|
1751 |
moduleDesc = new ModuleDescription(); |
|
1752 |
moduleDesc.name = name; |
|
1753 |
modules.put(moduleDesc.name, moduleDesc); |
|
1754 |
} |
|
1755 |
||
1756 |
addModuleHeader(moduleDesc, headerDesc, version); |
|
1757 |
} |
|
1758 |
||
1759 |
private void addModuleHeader(ModuleDescription moduleDesc, |
|
1760 |
ModuleHeaderDescription headerDesc, |
|
1761 |
String version) { |
|
1762 |
//normalize: |
|
1763 |
boolean existed = false; |
|
1764 |
for (ModuleHeaderDescription existing : moduleDesc.header) { |
|
1765 |
if (existing.equals(headerDesc)) { |
|
1766 |
headerDesc = existing; |
|
1767 |
existed = true; |
|
1768 |
} |
|
1769 |
} |
|
1770 |
||
1771 |
headerDesc.versions += version; |
|
1772 |
||
1773 |
if (!existed) { |
|
1774 |
moduleDesc.header.add(headerDesc); |
|
1775 |
} |
|
1776 |
} |
|
1777 |
||
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1778 |
private boolean include(int accessFlags) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1779 |
return (accessFlags & (AccessFlags.ACC_PUBLIC | AccessFlags.ACC_PROTECTED)) != 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1780 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1781 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1782 |
private void addClassHeader(ClassDescription clazzDesc, ClassHeaderDescription headerDesc, String version) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1783 |
//normalize: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1784 |
boolean existed = false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1785 |
for (ClassHeaderDescription existing : clazzDesc.header) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1786 |
if (existing.equals(headerDesc)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1787 |
headerDesc = existing; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1788 |
existed = true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1789 |
} else { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1790 |
//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
|
1791 |
//if so, copy it to the pre-8 version, so save space |
47703 | 1792 |
List<AnnotationDescription> annots = existing.classAnnotations; |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1793 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1794 |
if (annots != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1795 |
for (AnnotationDescription ad : annots) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1796 |
if (PROFILE_ANNOTATION.equals(ad.annotationType)) { |
47703 | 1797 |
existing.classAnnotations = new ArrayList<>(annots); |
1798 |
existing.classAnnotations.remove(ad); |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1799 |
if (existing.equals(headerDesc)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1800 |
headerDesc = existing; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1801 |
existed = true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1802 |
} |
47703 | 1803 |
existing.classAnnotations = annots; |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1804 |
break; |
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 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1807 |
} |
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 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1810 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1811 |
headerDesc.versions += version; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1812 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1813 |
if (!existed) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1814 |
clazzDesc.header.add(headerDesc); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1815 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1816 |
} |
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 |
private void addMethod(ClassDescription clazzDesc, MethodDescription methDesc, String version) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1819 |
//normalize: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1820 |
boolean methodExisted = false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1821 |
for (MethodDescription existing : clazzDesc.methods) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1822 |
if (existing.equals(methDesc)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1823 |
methodExisted = true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1824 |
methDesc = existing; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1825 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1826 |
} |
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 |
methDesc.versions += version; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1829 |
if (!methodExisted) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1830 |
clazzDesc.methods.add(methDesc); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1831 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1832 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1833 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1834 |
private void addField(ClassDescription clazzDesc, FieldDescription fieldDesc, String version) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1835 |
boolean fieldExisted = false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1836 |
for (FieldDescription existing : clazzDesc.fields) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1837 |
if (existing.equals(fieldDesc)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1838 |
fieldExisted = true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1839 |
fieldDesc = existing; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1840 |
break; |
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 |
fieldDesc.versions += version; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1844 |
if (!fieldExisted) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1845 |
clazzDesc.fields.add(fieldDesc); |
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 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1848 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1849 |
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
|
1850 |
String attrName = attr.getName(cf.constant_pool); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1851 |
switch (attrName) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1852 |
case Attribute.AnnotationDefault: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1853 |
assert feature instanceof MethodDescription; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1854 |
element_value defaultValue = ((AnnotationDefault_attribute) attr).default_value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1855 |
((MethodDescription) feature).annotationDefaultValue = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1856 |
convertElementValue(cf.constant_pool, defaultValue); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1857 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1858 |
case "Deprecated": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1859 |
feature.deprecated = true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1860 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1861 |
case "Exceptions": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1862 |
assert feature instanceof MethodDescription; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1863 |
List<String> thrownTypes = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1864 |
Exceptions_attribute exceptionAttr = (Exceptions_attribute) attr; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1865 |
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
|
1866 |
thrownTypes.add(exceptionAttr.getException(i, cf.constant_pool)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1867 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1868 |
((MethodDescription) feature).thrownTypes = thrownTypes; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1869 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1870 |
case Attribute.InnerClasses: |
47703 | 1871 |
if (feature instanceof ModuleHeaderDescription) |
1872 |
break; //XXX |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1873 |
assert feature instanceof ClassHeaderDescription; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1874 |
List<InnerClassInfo> innerClasses = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1875 |
InnerClasses_attribute innerClassesAttr = (InnerClasses_attribute) attr; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1876 |
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
|
1877 |
CONSTANT_Class_info outerClassInfo = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1878 |
innerClassesAttr.classes[i].getOuterClassInfo(cf.constant_pool); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1879 |
InnerClassInfo info = new InnerClassInfo(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1880 |
CONSTANT_Class_info innerClassInfo = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1881 |
innerClassesAttr.classes[i].getInnerClassInfo(cf.constant_pool); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1882 |
info.innerClass = innerClassInfo != null ? innerClassInfo.getName() : null; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1883 |
info.outerClass = outerClassInfo != null ? outerClassInfo.getName() : null; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1884 |
info.innerClassName = innerClassesAttr.classes[i].getInnerName(cf.constant_pool); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1885 |
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
|
1886 |
innerClasses.add(info); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1887 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1888 |
((ClassHeaderDescription) feature).innerClasses = innerClasses; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1889 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1890 |
case "RuntimeInvisibleAnnotations": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1891 |
feature.classAnnotations = annotations2Description(cf.constant_pool, attr); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1892 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1893 |
case "RuntimeVisibleAnnotations": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1894 |
feature.runtimeAnnotations = annotations2Description(cf.constant_pool, attr); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1895 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1896 |
case "Signature": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1897 |
feature.signature = ((Signature_attribute) attr).getSignature(cf.constant_pool); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1898 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1899 |
case "ConstantValue": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1900 |
assert feature instanceof FieldDescription; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1901 |
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
|
1902 |
if (((FieldDescription) feature).descriptor.equals("C")) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1903 |
value = (char) (int) value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1904 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1905 |
((FieldDescription) feature).constantValue = value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1906 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1907 |
case "SourceFile": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1908 |
//ignore, not needed |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1909 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1910 |
case "BootstrapMethods": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1911 |
//ignore, not needed |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1912 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1913 |
case "Code": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1914 |
//ignore, not needed |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1915 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1916 |
case "EnclosingMethod": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1917 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1918 |
case "Synthetic": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1919 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1920 |
case "RuntimeVisibleParameterAnnotations": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1921 |
assert feature instanceof MethodDescription; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1922 |
((MethodDescription) feature).runtimeParameterAnnotations = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1923 |
parameterAnnotations2Description(cf.constant_pool, attr); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1924 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1925 |
case "RuntimeInvisibleParameterAnnotations": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1926 |
assert feature instanceof MethodDescription; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1927 |
((MethodDescription) feature).classParameterAnnotations = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1928 |
parameterAnnotations2Description(cf.constant_pool, attr); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1929 |
break; |
47703 | 1930 |
case Attribute.Module: { |
1931 |
assert feature instanceof ModuleHeaderDescription; |
|
1932 |
ModuleHeaderDescription header = |
|
1933 |
(ModuleHeaderDescription) feature; |
|
1934 |
Module_attribute mod = (Module_attribute) attr; |
|
1935 |
||
1936 |
header.name = cf.constant_pool |
|
1937 |
.getModuleInfo(mod.module_name) |
|
1938 |
.getName(); |
|
1939 |
||
1940 |
header.exports = |
|
1941 |
Arrays.stream(mod.exports) |
|
1942 |
.filter(ee -> ee.exports_to_count == 0) |
|
1943 |
.map(ee -> getPackageName(cf, ee.exports_index)) |
|
1944 |
.collect(Collectors.toList()); |
|
1945 |
header.requires = |
|
1946 |
Arrays.stream(mod.requires) |
|
1947 |
.map(r -> RequiresDescription.create(cf, r)) |
|
1948 |
.collect(Collectors.toList()); |
|
1949 |
header.uses = Arrays.stream(mod.uses_index) |
|
1950 |
.mapToObj(use -> getClassName(cf, use)) |
|
1951 |
.collect(Collectors.toList()); |
|
1952 |
header.provides = |
|
1953 |
Arrays.stream(mod.provides) |
|
1954 |
.map(p -> ProvidesDescription.create(cf, p)) |
|
1955 |
.collect(Collectors.toList()); |
|
1956 |
break; |
|
1957 |
} |
|
1958 |
case Attribute.ModuleTarget: { |
|
1959 |
assert feature instanceof ModuleHeaderDescription; |
|
1960 |
ModuleHeaderDescription header = |
|
1961 |
(ModuleHeaderDescription) feature; |
|
1962 |
ModuleTarget_attribute mod = (ModuleTarget_attribute) attr; |
|
1963 |
if (mod.target_platform_index != 0) { |
|
1964 |
header.moduleTarget = |
|
1965 |
cf.constant_pool |
|
1966 |
.getUTF8Value(mod.target_platform_index); |
|
1967 |
} |
|
1968 |
break; |
|
1969 |
} |
|
1970 |
case Attribute.ModuleResolution: { |
|
1971 |
assert feature instanceof ModuleHeaderDescription; |
|
1972 |
ModuleHeaderDescription header = |
|
1973 |
(ModuleHeaderDescription) feature; |
|
1974 |
ModuleResolution_attribute mod = |
|
1975 |
(ModuleResolution_attribute) attr; |
|
1976 |
header.moduleResolution = mod.resolution_flags; |
|
1977 |
break; |
|
1978 |
} |
|
1979 |
case Attribute.ModulePackages: |
|
1980 |
case Attribute.ModuleHashes: |
|
1981 |
break; |
|
51799 | 1982 |
case Attribute.NestHost: { |
1983 |
assert feature instanceof ClassHeaderDescription; |
|
1984 |
NestHost_attribute nestHost = (NestHost_attribute) attr; |
|
1985 |
ClassHeaderDescription chd = (ClassHeaderDescription) feature; |
|
1986 |
chd.nestHost = nestHost.getNestTop(cf.constant_pool).getName(); |
|
1987 |
break; |
|
1988 |
} |
|
1989 |
case Attribute.NestMembers: { |
|
1990 |
assert feature instanceof ClassHeaderDescription; |
|
1991 |
NestMembers_attribute nestMembers = (NestMembers_attribute) attr; |
|
1992 |
ClassHeaderDescription chd = (ClassHeaderDescription) feature; |
|
1993 |
chd.nestMembers = Arrays.stream(nestMembers.members_indexes) |
|
1994 |
.mapToObj(i -> getClassName(cf, i)) |
|
1995 |
.collect(Collectors.toList()); |
|
1996 |
break; |
|
1997 |
} |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
1998 |
default: |
47703 | 1999 |
throw new IllegalStateException("Unhandled attribute: " + |
2000 |
attrName); |
|
31506
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2003 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2004 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2005 |
|
47703 | 2006 |
private static String getClassName(ClassFile cf, int idx) { |
2007 |
try { |
|
2008 |
return cf.constant_pool.getClassInfo(idx).getName(); |
|
2009 |
} catch (InvalidIndex ex) { |
|
2010 |
throw new IllegalStateException(ex); |
|
2011 |
} catch (ConstantPool.UnexpectedEntry ex) { |
|
2012 |
throw new IllegalStateException(ex); |
|
2013 |
} catch (ConstantPoolException ex) { |
|
2014 |
throw new IllegalStateException(ex); |
|
2015 |
} |
|
2016 |
} |
|
2017 |
||
2018 |
private static String getPackageName(ClassFile cf, int idx) { |
|
2019 |
try { |
|
2020 |
return cf.constant_pool.getPackageInfo(idx).getName(); |
|
2021 |
} catch (InvalidIndex ex) { |
|
2022 |
throw new IllegalStateException(ex); |
|
2023 |
} catch (ConstantPool.UnexpectedEntry ex) { |
|
2024 |
throw new IllegalStateException(ex); |
|
2025 |
} catch (ConstantPoolException ex) { |
|
2026 |
throw new IllegalStateException(ex); |
|
2027 |
} |
|
2028 |
} |
|
2029 |
||
2030 |
private static String getModuleName(ClassFile cf, int idx) { |
|
2031 |
try { |
|
2032 |
return cf.constant_pool.getModuleInfo(idx).getName(); |
|
2033 |
} catch (InvalidIndex ex) { |
|
2034 |
throw new IllegalStateException(ex); |
|
2035 |
} catch (ConstantPool.UnexpectedEntry ex) { |
|
2036 |
throw new IllegalStateException(ex); |
|
2037 |
} catch (ConstantPoolException ex) { |
|
2038 |
throw new IllegalStateException(ex); |
|
2039 |
} |
|
2040 |
} |
|
2041 |
||
2042 |
private static Integer getVersion(ClassFile cf, int idx) { |
|
2043 |
if (idx == 0) |
|
2044 |
return null; |
|
2045 |
try { |
|
2046 |
return ((CONSTANT_Integer_info) cf.constant_pool.get(idx)).value; |
|
2047 |
} catch (InvalidIndex ex) { |
|
2048 |
throw new IllegalStateException(ex); |
|
2049 |
} |
|
2050 |
} |
|
2051 |
||
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2052 |
Object convertConstantValue(CPInfo info, String descriptor) throws ConstantPoolException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2053 |
if (info instanceof CONSTANT_Integer_info) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2054 |
if ("Z".equals(descriptor)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2055 |
return ((CONSTANT_Integer_info) info).value == 1; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2056 |
else |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2057 |
return ((CONSTANT_Integer_info) info).value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2058 |
} else if (info instanceof CONSTANT_Long_info) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2059 |
return ((CONSTANT_Long_info) info).value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2060 |
} else if (info instanceof CONSTANT_Float_info) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2061 |
return ((CONSTANT_Float_info) info).value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2062 |
} else if (info instanceof CONSTANT_Double_info) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2063 |
return ((CONSTANT_Double_info) info).value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2064 |
} else if (info instanceof CONSTANT_String_info) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2065 |
return ((CONSTANT_String_info) info).getString(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2066 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2067 |
throw new IllegalStateException(info.getClass().getName()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2068 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2069 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2070 |
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
|
2071 |
switch (val.tag) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2072 |
case 'Z': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2073 |
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
|
2074 |
case 'B': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2075 |
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
|
2076 |
case 'C': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2077 |
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
|
2078 |
case 'S': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2079 |
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
|
2080 |
case 'I': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2081 |
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
|
2082 |
case 'J': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2083 |
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
|
2084 |
case 'F': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2085 |
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
|
2086 |
case 'D': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2087 |
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
|
2088 |
case 's': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2089 |
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
|
2090 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2091 |
case 'e': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2092 |
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
|
2093 |
cp.getUTF8Value(((Enum_element_value) val).const_name_index)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2094 |
case 'c': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2095 |
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
|
2096 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2097 |
case '@': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2098 |
return annotation2Description(cp, ((Annotation_element_value) val).annotation_value); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2099 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2100 |
case '[': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2101 |
List<Object> values = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2102 |
for (element_value elem : ((Array_element_value) val).values) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2103 |
values.add(convertElementValue(cp, elem)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2104 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2105 |
return values; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2106 |
default: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2107 |
throw new IllegalStateException("Currently unhandled tag: " + val.tag); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2108 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2109 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2110 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2111 |
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
|
2112 |
RuntimeAnnotations_attribute annotationsAttr = (RuntimeAnnotations_attribute) attr; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2113 |
List<AnnotationDescription> descs = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2114 |
for (Annotation a : annotationsAttr.annotations) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2115 |
descs.add(annotation2Description(cp, a)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2116 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2117 |
return descs; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2118 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2119 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2120 |
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
|
2121 |
RuntimeParameterAnnotations_attribute annotationsAttr = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2122 |
(RuntimeParameterAnnotations_attribute) attr; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2123 |
List<List<AnnotationDescription>> descs = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2124 |
for (Annotation[] attrAnnos : annotationsAttr.parameter_annotations) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2125 |
List<AnnotationDescription> paramDescs = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2126 |
for (Annotation ann : attrAnnos) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2127 |
paramDescs.add(annotation2Description(cp, ann)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2128 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2129 |
descs.add(paramDescs); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2130 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2131 |
return descs; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2132 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2133 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2134 |
private AnnotationDescription annotation2Description(ConstantPool cp, Annotation a) throws ConstantPoolException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2135 |
String annotationType = cp.getUTF8Value(a.type_index); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2136 |
Map<String, Object> values = new HashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2137 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2138 |
for (element_value_pair e : a.element_value_pairs) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2139 |
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
|
2140 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2141 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2142 |
return new AnnotationDescription(annotationType, values); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2143 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2144 |
//</editor-fold> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2145 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2146 |
protected boolean includeEffectiveAccess(ClassList classes, ClassDescription clazz) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2147 |
if (!include(clazz.header.get(0).flags)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2148 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2149 |
for (ClassDescription outer : classes.enclosingClasses(clazz)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2150 |
if (!include(outer.header.get(0).flags)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2151 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2152 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2153 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2154 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2155 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2156 |
boolean include(Set<String> includedClasses, ClassList classes, String clazzName) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2157 |
if (clazzName == null) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2158 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2159 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2160 |
boolean modified = includedClasses.add(clazzName); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2161 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2162 |
for (ClassDescription outer : classes.enclosingClasses(classes.find(clazzName, true))) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2163 |
modified |= includedClasses.add(outer.name); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2164 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2165 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2166 |
return modified; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2167 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2168 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2169 |
<T extends FeatureDescription> boolean includeOutputType(Iterable<T> features, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2170 |
Function<T, String> feature2Descriptor, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2171 |
Set<String> includedClasses, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2172 |
ClassList classes) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2173 |
boolean modified = false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2174 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2175 |
for (T feature : features) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2176 |
CharSequence sig = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2177 |
feature.signature != null ? feature.signature : feature2Descriptor.apply(feature); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2178 |
Matcher m = OUTPUT_TYPE_PATTERN.matcher(sig); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2179 |
while (m.find()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2180 |
modified |= include(includedClasses, classes, m.group(1)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2181 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2182 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2183 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2184 |
return modified; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2185 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2186 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2187 |
static final Pattern OUTPUT_TYPE_PATTERN = Pattern.compile("L([^;<]+)(;|<)"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2188 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2189 |
public static class VersionDescription { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2190 |
public final String classes; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2191 |
public final String version; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2192 |
public final String primaryBaseline; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2193 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2194 |
public VersionDescription(String classes, String version, String primaryBaseline) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2195 |
this.classes = classes; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2196 |
this.version = version; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2197 |
this.primaryBaseline = "<none>".equals(primaryBaseline) ? null : primaryBaseline; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2198 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2199 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2200 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2201 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2202 |
public static class ExcludeIncludeList { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2203 |
public final Set<String> includeList; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2204 |
public final Set<String> excludeList; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2205 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2206 |
protected ExcludeIncludeList(Set<String> includeList, Set<String> excludeList) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2207 |
this.includeList = includeList; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2208 |
this.excludeList = excludeList; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2209 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2210 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2211 |
public static ExcludeIncludeList create(String files) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2212 |
Set<String> includeList = new HashSet<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2213 |
Set<String> excludeList = new HashSet<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2214 |
for (String file : files.split(File.pathSeparator)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2215 |
try (Stream<String> lines = Files.lines(Paths.get(file))) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2216 |
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
|
2217 |
.filter(l -> !l.trim().isEmpty()) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2218 |
.forEach(l -> { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2219 |
Set<String> target = l.startsWith("+") ? includeList : excludeList; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2220 |
target.add(l.substring(1)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2221 |
}); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2222 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2223 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2224 |
return new ExcludeIncludeList(includeList, excludeList); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2225 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2226 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2227 |
public boolean accepts(String className) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2228 |
return matches(includeList, className) && !matches(excludeList, className); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2229 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2230 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2231 |
private static boolean matches(Set<String> list, String className) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2232 |
if (list.contains(className)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2233 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2234 |
String pack = className.substring(0, className.lastIndexOf('/') + 1); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2235 |
return list.contains(pack); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2236 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2237 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2238 |
//</editor-fold> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2239 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2240 |
//<editor-fold defaultstate="collapsed" desc="Class Data Structures"> |
47703 | 2241 |
static boolean checkChange(String versions, String version, |
2242 |
String baselineVersion) { |
|
2243 |
return versions.contains(version) ^ |
|
2244 |
(baselineVersion != null && |
|
2245 |
versions.contains(baselineVersion)); |
|
2246 |
} |
|
2247 |
||
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2248 |
static abstract class FeatureDescription { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2249 |
int flags; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2250 |
boolean deprecated; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2251 |
String signature; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2252 |
String versions = ""; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2253 |
List<AnnotationDescription> classAnnotations; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2254 |
List<AnnotationDescription> runtimeAnnotations; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2255 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2256 |
protected void writeAttributes(Appendable output) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2257 |
if (flags != 0) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2258 |
output.append(" flags " + Integer.toHexString(flags)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2259 |
if (deprecated) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2260 |
output.append(" deprecated true"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2261 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2262 |
if (signature != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2263 |
output.append(" signature " + quote(signature, false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2264 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2265 |
if (classAnnotations != null && !classAnnotations.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2266 |
output.append(" classAnnotations "); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2267 |
for (AnnotationDescription a : classAnnotations) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2268 |
output.append(quote(a.toString(), false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2269 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2270 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2271 |
if (runtimeAnnotations != null && !runtimeAnnotations.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2272 |
output.append(" runtimeAnnotations "); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2273 |
for (AnnotationDescription a : runtimeAnnotations) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2274 |
output.append(quote(a.toString(), false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2275 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2276 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2277 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2278 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2279 |
protected boolean shouldIgnore(String baselineVersion, String version) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2280 |
return (!versions.contains(version) && |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2281 |
(baselineVersion == null || !versions.contains(baselineVersion))) || |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2282 |
(baselineVersion != null && |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2283 |
versions.contains(baselineVersion) && versions.contains(version)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2284 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2285 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2286 |
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
|
2287 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2288 |
protected void readAttributes(LineBasedReader reader) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2289 |
String inFlags = reader.attributes.get("flags"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2290 |
if (inFlags != null && !inFlags.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2291 |
flags = Integer.parseInt(inFlags, 16); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2292 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2293 |
String inDeprecated = reader.attributes.get("deprecated"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2294 |
if ("true".equals(inDeprecated)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2295 |
deprecated = true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2296 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2297 |
signature = reader.attributes.get("signature"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2298 |
String inClassAnnotations = reader.attributes.get("classAnnotations"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2299 |
if (inClassAnnotations != null) { |
50027 | 2300 |
classAnnotations = parseAnnotations(inClassAnnotations, new int[1]); |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2301 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2302 |
String inRuntimeAnnotations = reader.attributes.get("runtimeAnnotations"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2303 |
if (inRuntimeAnnotations != null) { |
50027 | 2304 |
runtimeAnnotations = parseAnnotations(inRuntimeAnnotations, new int[1]); |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2305 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2306 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2307 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2308 |
public abstract boolean read(LineBasedReader reader) throws IOException; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2309 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2310 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2311 |
public int hashCode() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2312 |
int hash = 3; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2313 |
hash = 89 * hash + this.flags; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2314 |
hash = 89 * hash + (this.deprecated ? 1 : 0); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2315 |
hash = 89 * hash + Objects.hashCode(this.signature); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2316 |
hash = 89 * hash + listHashCode(this.classAnnotations); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2317 |
hash = 89 * hash + listHashCode(this.runtimeAnnotations); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2318 |
return hash; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2319 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2320 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2321 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2322 |
public boolean equals(Object obj) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2323 |
if (obj == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2324 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2325 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2326 |
if (getClass() != obj.getClass()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2327 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2328 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2329 |
final FeatureDescription other = (FeatureDescription) obj; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2330 |
if (this.flags != other.flags) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2331 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2332 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2333 |
if (this.deprecated != other.deprecated) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2334 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2335 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2336 |
if (!Objects.equals(this.signature, other.signature)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2337 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2338 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2339 |
if (!listEquals(this.classAnnotations, other.classAnnotations)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2340 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2341 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2342 |
if (!listEquals(this.runtimeAnnotations, other.runtimeAnnotations)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2343 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2344 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2345 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2346 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2347 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2348 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2349 |
|
47703 | 2350 |
public static class ModuleDescription { |
2351 |
String name; |
|
2352 |
List<ModuleHeaderDescription> header = new ArrayList<>(); |
|
2353 |
||
2354 |
public void write(Appendable output, String baselineVersion, |
|
2355 |
String version) throws IOException { |
|
2356 |
boolean inBaseline = false; |
|
2357 |
boolean inVersion = false; |
|
2358 |
for (ModuleHeaderDescription mhd : header) { |
|
2359 |
if (baselineVersion != null && |
|
2360 |
mhd.versions.contains(baselineVersion)) { |
|
2361 |
inBaseline = true; |
|
2362 |
} |
|
2363 |
if (mhd.versions.contains(version)) { |
|
2364 |
inVersion = true; |
|
2365 |
} |
|
2366 |
} |
|
2367 |
if (!inVersion && !inBaseline) |
|
2368 |
return ; |
|
2369 |
if (!inVersion) { |
|
2370 |
output.append("-module name " + name + "\n\n"); |
|
2371 |
return; |
|
2372 |
} |
|
2373 |
boolean hasChange = hasChange(header, version, baselineVersion); |
|
2374 |
if (!hasChange) |
|
2375 |
return; |
|
2376 |
||
2377 |
output.append("module name " + name + "\n"); |
|
2378 |
for (ModuleHeaderDescription header : header) { |
|
2379 |
header.write(output, baselineVersion, version); |
|
2380 |
} |
|
2381 |
output.append("\n"); |
|
2382 |
} |
|
2383 |
||
2384 |
boolean hasChange(List<? extends FeatureDescription> hasChange, |
|
2385 |
String version, String baseline) { |
|
2386 |
return hasChange.stream() |
|
2387 |
.map(fd -> fd.versions) |
|
2388 |
.anyMatch(versions -> checkChange(versions, |
|
2389 |
version, |
|
2390 |
baseline)); |
|
2391 |
} |
|
2392 |
||
2393 |
public void read(LineBasedReader reader, String baselineVersion, |
|
2394 |
String version) throws IOException { |
|
2395 |
if (!"module".equals(reader.lineKey)) |
|
2396 |
return ; |
|
2397 |
||
2398 |
name = reader.attributes.get("name"); |
|
2399 |
||
2400 |
reader.moveNext(); |
|
2401 |
||
2402 |
OUTER: while (reader.hasNext()) { |
|
2403 |
switch (reader.lineKey) { |
|
2404 |
case "header": |
|
2405 |
removeVersion(header, h -> true, version); |
|
2406 |
ModuleHeaderDescription mhd = |
|
2407 |
new ModuleHeaderDescription(); |
|
2408 |
mhd.read(reader); |
|
50027 | 2409 |
mhd.name = name; |
47703 | 2410 |
mhd.versions = version; |
2411 |
header.add(mhd); |
|
2412 |
break; |
|
2413 |
case "class": |
|
2414 |
case "-class": |
|
2415 |
case "module": |
|
2416 |
case "-module": |
|
2417 |
break OUTER; |
|
2418 |
default: |
|
2419 |
throw new IllegalStateException(reader.lineKey); |
|
2420 |
} |
|
2421 |
} |
|
2422 |
} |
|
2423 |
} |
|
2424 |
||
2425 |
static class ModuleHeaderDescription extends HeaderDescription { |
|
2426 |
String name; |
|
2427 |
List<String> exports = new ArrayList<>(); |
|
2428 |
List<String> opens = new ArrayList<>(); |
|
2429 |
List<RequiresDescription> requires = new ArrayList<>(); |
|
2430 |
List<String> uses = new ArrayList<>(); |
|
2431 |
List<ProvidesDescription> provides = new ArrayList<>(); |
|
2432 |
Integer moduleResolution; |
|
2433 |
String moduleTarget; |
|
2434 |
||
2435 |
@Override |
|
2436 |
public int hashCode() { |
|
2437 |
int hash = super.hashCode(); |
|
2438 |
hash = 83 * hash + Objects.hashCode(this.name); |
|
2439 |
hash = 83 * hash + Objects.hashCode(this.exports); |
|
2440 |
hash = 83 * hash + Objects.hashCode(this.opens); |
|
2441 |
hash = 83 * hash + Objects.hashCode(this.requires); |
|
2442 |
hash = 83 * hash + Objects.hashCode(this.uses); |
|
2443 |
hash = 83 * hash + Objects.hashCode(this.provides); |
|
2444 |
hash = 83 * hash + Objects.hashCode(this.moduleResolution); |
|
2445 |
hash = 83 * hash + Objects.hashCode(this.moduleTarget); |
|
2446 |
return hash; |
|
2447 |
} |
|
2448 |
||
2449 |
@Override |
|
2450 |
public boolean equals(Object obj) { |
|
2451 |
if (this == obj) { |
|
2452 |
return true; |
|
2453 |
} |
|
2454 |
if (!super.equals(obj)) { |
|
2455 |
return false; |
|
2456 |
} |
|
2457 |
final ModuleHeaderDescription other = |
|
2458 |
(ModuleHeaderDescription) obj; |
|
2459 |
if (!Objects.equals(this.name, other.name)) { |
|
2460 |
return false; |
|
2461 |
} |
|
2462 |
if (!listEquals(this.exports, other.exports)) { |
|
2463 |
return false; |
|
2464 |
} |
|
2465 |
if (!listEquals(this.opens, other.opens)) { |
|
2466 |
return false; |
|
2467 |
} |
|
2468 |
if (!listEquals(this.requires, other.requires)) { |
|
2469 |
return false; |
|
2470 |
} |
|
2471 |
if (!listEquals(this.uses, other.uses)) { |
|
2472 |
return false; |
|
2473 |
} |
|
2474 |
if (!listEquals(this.provides, other.provides)) { |
|
2475 |
return false; |
|
2476 |
} |
|
2477 |
if (!Objects.equals(this.moduleTarget, other.moduleTarget)) { |
|
2478 |
return false; |
|
2479 |
} |
|
2480 |
if (!Objects.equals(this.moduleResolution, |
|
2481 |
other.moduleResolution)) { |
|
2482 |
return false; |
|
2483 |
} |
|
2484 |
return true; |
|
2485 |
} |
|
2486 |
||
2487 |
@Override |
|
2488 |
public void write(Appendable output, String baselineVersion, |
|
2489 |
String version) throws IOException { |
|
2490 |
if (!versions.contains(version) || |
|
2491 |
(baselineVersion != null && versions.contains(baselineVersion) |
|
2492 |
&& versions.contains(version))) |
|
2493 |
return ; |
|
2494 |
output.append("header"); |
|
2495 |
if (exports != null && !exports.isEmpty()) |
|
2496 |
output.append(" exports " + serializeList(exports)); |
|
2497 |
if (opens != null && !opens.isEmpty()) |
|
2498 |
output.append(" opens " + serializeList(opens)); |
|
2499 |
if (requires != null && !requires.isEmpty()) { |
|
2500 |
List<String> requiresList = |
|
2501 |
requires.stream() |
|
2502 |
.map(req -> req.serialize()) |
|
2503 |
.collect(Collectors.toList()); |
|
2504 |
output.append(" requires " + serializeList(requiresList)); |
|
2505 |
} |
|
2506 |
if (uses != null && !uses.isEmpty()) |
|
2507 |
output.append(" uses " + serializeList(uses)); |
|
2508 |
if (provides != null && !provides.isEmpty()) { |
|
2509 |
List<String> providesList = |
|
2510 |
provides.stream() |
|
2511 |
.map(p -> p.serialize()) |
|
2512 |
.collect(Collectors.toList()); |
|
2513 |
output.append(" provides " + serializeList(providesList)); |
|
2514 |
} |
|
2515 |
if (moduleTarget != null) |
|
2516 |
output.append(" target " + quote(moduleTarget, true)); |
|
2517 |
if (moduleResolution != null) |
|
2518 |
output.append(" resolution " + |
|
2519 |
quote(Integer.toHexString(moduleResolution), |
|
2520 |
true)); |
|
2521 |
writeAttributes(output); |
|
2522 |
output.append("\n"); |
|
2523 |
writeInnerClasses(output, baselineVersion, version); |
|
2524 |
} |
|
2525 |
||
2526 |
private static Map<String, String> splitAttributes(String data) { |
|
2527 |
String[] parts = data.split(" "); |
|
2528 |
||
2529 |
Map<String, String> attributes = new HashMap<>(); |
|
2530 |
||
2531 |
for (int i = 0; i < parts.length; i += 2) { |
|
2532 |
attributes.put(parts[i], unquote(parts[i + 1])); |
|
2533 |
} |
|
2534 |
||
2535 |
return attributes; |
|
2536 |
} |
|
2537 |
||
2538 |
@Override |
|
2539 |
public boolean read(LineBasedReader reader) throws IOException { |
|
2540 |
if (!"header".equals(reader.lineKey)) |
|
2541 |
return false; |
|
2542 |
||
2543 |
exports = deserializeList(reader.attributes.get("exports")); |
|
2544 |
opens = deserializeList(reader.attributes.get("opens")); |
|
2545 |
List<String> requiresList = |
|
2546 |
deserializeList(reader.attributes.get("requires")); |
|
2547 |
requires = requiresList.stream() |
|
2548 |
.map(RequiresDescription::deserialize) |
|
2549 |
.collect(Collectors.toList()); |
|
2550 |
uses = deserializeList(reader.attributes.get("uses")); |
|
2551 |
List<String> providesList = |
|
2552 |
deserializeList(reader.attributes.get("provides"), false); |
|
2553 |
provides = providesList.stream() |
|
2554 |
.map(ProvidesDescription::deserialize) |
|
2555 |
.collect(Collectors.toList()); |
|
2556 |
||
2557 |
moduleTarget = reader.attributes.get("target"); |
|
2558 |
||
2559 |
if (reader.attributes.containsKey("resolution")) { |
|
2560 |
final String resolutionFlags = |
|
2561 |
reader.attributes.get("resolution"); |
|
2562 |
moduleResolution = Integer.parseInt(resolutionFlags, 16); |
|
2563 |
} |
|
2564 |
||
2565 |
readAttributes(reader); |
|
2566 |
reader.moveNext(); |
|
2567 |
readInnerClasses(reader); |
|
2568 |
||
2569 |
return true; |
|
2570 |
} |
|
2571 |
||
2572 |
static class RequiresDescription { |
|
2573 |
final String moduleName; |
|
2574 |
final int flags; |
|
2575 |
final Integer version; |
|
2576 |
||
2577 |
public RequiresDescription(String moduleName, int flags, |
|
2578 |
Integer version) { |
|
2579 |
this.moduleName = moduleName; |
|
2580 |
this.flags = flags; |
|
2581 |
this.version = version; |
|
2582 |
} |
|
2583 |
||
2584 |
public String serialize() { |
|
2585 |
String versionKeyValue = version != null |
|
2586 |
? " version " + quote(String.valueOf(version), true) |
|
2587 |
: ""; |
|
2588 |
return "name " + quote(moduleName, true) + |
|
2589 |
" flags " + quote(Integer.toHexString(flags), true) + |
|
2590 |
versionKeyValue; |
|
2591 |
} |
|
2592 |
||
2593 |
public static RequiresDescription deserialize(String data) { |
|
2594 |
Map<String, String> attributes = splitAttributes(data); |
|
2595 |
||
2596 |
Integer ver = attributes.containsKey("version") |
|
2597 |
? Integer.parseInt(attributes.get("version")) |
|
2598 |
: null; |
|
2599 |
int flags = Integer.parseInt(attributes.get("flags"), 16); |
|
2600 |
return new RequiresDescription(attributes.get("name"), |
|
2601 |
flags, |
|
2602 |
ver); |
|
2603 |
} |
|
2604 |
||
2605 |
public static RequiresDescription create(ClassFile cf, |
|
2606 |
RequiresEntry req) { |
|
2607 |
String mod = getModuleName(cf, req.requires_index); |
|
2608 |
Integer ver = getVersion(cf, req.requires_version_index); |
|
2609 |
return new RequiresDescription(mod, |
|
2610 |
req.requires_flags, |
|
2611 |
ver); |
|
2612 |
} |
|
2613 |
} |
|
2614 |
||
2615 |
static class ProvidesDescription { |
|
2616 |
final String interfaceName; |
|
2617 |
final List<String> implNames; |
|
2618 |
||
2619 |
public ProvidesDescription(String interfaceName, |
|
2620 |
List<String> implNames) { |
|
2621 |
this.interfaceName = interfaceName; |
|
2622 |
this.implNames = implNames; |
|
2623 |
} |
|
2624 |
||
2625 |
public String serialize() { |
|
2626 |
return "interface " + quote(interfaceName, true) + |
|
2627 |
" impls " + quote(serializeList(implNames), true, true); |
|
2628 |
} |
|
2629 |
||
2630 |
public static ProvidesDescription deserialize(String data) { |
|
2631 |
Map<String, String> attributes = splitAttributes(data); |
|
2632 |
List<String> implsList = |
|
2633 |
deserializeList(attributes.get("impls"), |
|
2634 |
false); |
|
2635 |
return new ProvidesDescription(attributes.get("interface"), |
|
2636 |
implsList); |
|
2637 |
} |
|
2638 |
||
2639 |
public static ProvidesDescription create(ClassFile cf, |
|
2640 |
ProvidesEntry prov) { |
|
2641 |
String api = getClassName(cf, prov.provides_index); |
|
2642 |
List<String> impls = |
|
2643 |
Arrays.stream(prov.with_index) |
|
2644 |
.mapToObj(wi -> getClassName(cf, wi)) |
|
2645 |
.collect(Collectors.toList()); |
|
2646 |
return new ProvidesDescription(api, impls); |
|
2647 |
} |
|
2648 |
} |
|
2649 |
} |
|
2650 |
||
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2651 |
public static class ClassDescription { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2652 |
String name; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2653 |
List<ClassHeaderDescription> header = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2654 |
List<MethodDescription> methods = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2655 |
List<FieldDescription> fields = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2656 |
|
47703 | 2657 |
public void write(Appendable output, String baselineVersion, |
2658 |
String version) throws IOException { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2659 |
boolean inBaseline = false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2660 |
boolean inVersion = false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2661 |
for (ClassHeaderDescription chd : header) { |
47703 | 2662 |
if (baselineVersion != null && |
2663 |
chd.versions.contains(baselineVersion)) { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2664 |
inBaseline = true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2665 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2666 |
if (chd.versions.contains(version)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2667 |
inVersion = true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2668 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2669 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2670 |
if (!inVersion && !inBaseline) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2671 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2672 |
if (!inVersion) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2673 |
output.append("-class name " + name + "\n\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2674 |
return; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2675 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2676 |
boolean hasChange = hasChange(header, version, baselineVersion) || |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2677 |
hasChange(fields, version, baselineVersion) || |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2678 |
hasChange(methods, version, baselineVersion); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2679 |
if (!hasChange) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2680 |
return; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2681 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2682 |
output.append("class name " + name + "\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2683 |
for (ClassHeaderDescription header : header) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2684 |
header.write(output, baselineVersion, version); |
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 |
for (FieldDescription field : fields) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2687 |
field.write(output, baselineVersion, version); |
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 |
for (MethodDescription method : methods) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2690 |
method.write(output, baselineVersion, version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2691 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2692 |
output.append("\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2693 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2694 |
|
47703 | 2695 |
boolean hasChange(List<? extends FeatureDescription> hasChange, |
2696 |
String version, |
|
2697 |
String baseline) { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2698 |
return hasChange.stream() |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2699 |
.map(fd -> fd.versions) |
47703 | 2700 |
.anyMatch(versions -> checkChange(versions, |
2701 |
version, |
|
2702 |
baseline)); |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2703 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2704 |
|
47703 | 2705 |
public void read(LineBasedReader reader, String baselineVersion, |
2706 |
String version) throws IOException { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2707 |
if (!"class".equals(reader.lineKey)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2708 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2709 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2710 |
name = reader.attributes.get("name"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2711 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2712 |
reader.moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2713 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2714 |
OUTER: while (reader.hasNext()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2715 |
switch (reader.lineKey) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2716 |
case "header": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2717 |
removeVersion(header, h -> true, version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2718 |
ClassHeaderDescription chd = new ClassHeaderDescription(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2719 |
chd.read(reader); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2720 |
chd.versions = version; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2721 |
header.add(chd); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2722 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2723 |
case "field": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2724 |
FieldDescription field = new FieldDescription(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2725 |
field.read(reader); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2726 |
field.versions += version; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2727 |
fields.add(field); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2728 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2729 |
case "-field": { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2730 |
removeVersion(fields, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2731 |
f -> Objects.equals(f.name, reader.attributes.get("name")) && |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2732 |
Objects.equals(f.descriptor, reader.attributes.get("descriptor")), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2733 |
version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2734 |
reader.moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2735 |
break; |
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 |
case "method": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2738 |
MethodDescription method = new MethodDescription(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2739 |
method.read(reader); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2740 |
method.versions += version; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2741 |
methods.add(method); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2742 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2743 |
case "-method": { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2744 |
removeVersion(methods, |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2745 |
m -> Objects.equals(m.name, reader.attributes.get("name")) && |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2746 |
Objects.equals(m.descriptor, reader.attributes.get("descriptor")), |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2747 |
version); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2748 |
reader.moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2749 |
break; |
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 |
case "class": |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2752 |
case "-class": |
47703 | 2753 |
case "module": |
2754 |
case "-module": |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2755 |
break OUTER; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2756 |
default: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2757 |
throw new IllegalStateException(reader.lineKey); |
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 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2760 |
} |
47703 | 2761 |
|
2762 |
public String packge() { |
|
2763 |
String pack; |
|
2764 |
int lastSlash = name.lastIndexOf('/'); |
|
2765 |
if (lastSlash != (-1)) { |
|
2766 |
pack = name.substring(0, lastSlash).replace('/', '.'); |
|
2767 |
} else { |
|
2768 |
pack = ""; |
|
2769 |
} |
|
2770 |
||
2771 |
return pack; |
|
2772 |
} |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2773 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2774 |
|
47703 | 2775 |
static class ClassHeaderDescription extends HeaderDescription { |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2776 |
String extendsAttr; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2777 |
List<String> implementsAttr; |
51799 | 2778 |
String nestHost; |
2779 |
List<String> nestMembers; |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2780 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2781 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2782 |
public int hashCode() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2783 |
int hash = super.hashCode(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2784 |
hash = 17 * hash + Objects.hashCode(this.extendsAttr); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2785 |
hash = 17 * hash + Objects.hashCode(this.implementsAttr); |
51799 | 2786 |
hash = 17 * hash + Objects.hashCode(this.nestHost); |
2787 |
hash = 17 * hash + Objects.hashCode(this.nestMembers); |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2788 |
return hash; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2789 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2790 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2791 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2792 |
public boolean equals(Object obj) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2793 |
if (obj == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2794 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2795 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2796 |
if (!super.equals(obj)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2797 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2798 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2799 |
final ClassHeaderDescription other = (ClassHeaderDescription) obj; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2800 |
if (!Objects.equals(this.extendsAttr, other.extendsAttr)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2801 |
return false; |
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 (!Objects.equals(this.implementsAttr, other.implementsAttr)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2804 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2805 |
} |
51799 | 2806 |
if (!Objects.equals(this.nestHost, other.nestHost)) { |
2807 |
return false; |
|
2808 |
} |
|
2809 |
if (!Objects.equals(this.nestMembers, other.nestMembers)) { |
|
2810 |
return false; |
|
2811 |
} |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2812 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2813 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2814 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2815 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2816 |
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
|
2817 |
if (!versions.contains(version) || |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2818 |
(baselineVersion != null && versions.contains(baselineVersion) && versions.contains(version))) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2819 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2820 |
output.append("header"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2821 |
if (extendsAttr != null) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2822 |
output.append(" extends " + extendsAttr); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2823 |
if (implementsAttr != null && !implementsAttr.isEmpty()) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2824 |
output.append(" implements " + serializeList(implementsAttr)); |
51799 | 2825 |
if (nestHost != null) |
2826 |
output.append(" nestHost " + nestHost); |
|
2827 |
if (nestMembers != null && !nestMembers.isEmpty()) |
|
2828 |
output.append(" nestMembers " + serializeList(nestMembers)); |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2829 |
writeAttributes(output); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2830 |
output.append("\n"); |
47703 | 2831 |
writeInnerClasses(output, baselineVersion, version); |
2832 |
} |
|
2833 |
||
2834 |
@Override |
|
2835 |
public boolean read(LineBasedReader reader) throws IOException { |
|
2836 |
if (!"header".equals(reader.lineKey)) |
|
2837 |
return false; |
|
2838 |
||
2839 |
extendsAttr = reader.attributes.get("extends"); |
|
2840 |
String elementsList = reader.attributes.get("implements"); |
|
2841 |
implementsAttr = deserializeList(elementsList); |
|
2842 |
||
51799 | 2843 |
nestHost = reader.attributes.get("nestHost"); |
2844 |
String nestMembersList = reader.attributes.get("nestMembers"); |
|
2845 |
nestMembers = deserializeList(nestMembersList); |
|
2846 |
||
47703 | 2847 |
readAttributes(reader); |
2848 |
reader.moveNext(); |
|
2849 |
readInnerClasses(reader); |
|
2850 |
||
2851 |
return true; |
|
2852 |
} |
|
2853 |
||
2854 |
} |
|
2855 |
||
2856 |
static abstract class HeaderDescription extends FeatureDescription { |
|
2857 |
List<InnerClassInfo> innerClasses; |
|
2858 |
||
2859 |
@Override |
|
2860 |
public int hashCode() { |
|
2861 |
int hash = super.hashCode(); |
|
2862 |
hash = 19 * hash + Objects.hashCode(this.innerClasses); |
|
2863 |
return hash; |
|
2864 |
} |
|
2865 |
||
2866 |
@Override |
|
2867 |
public boolean equals(Object obj) { |
|
2868 |
if (obj == null) { |
|
2869 |
return false; |
|
2870 |
} |
|
2871 |
if (!super.equals(obj)) { |
|
2872 |
return false; |
|
2873 |
} |
|
2874 |
final HeaderDescription other = (HeaderDescription) obj; |
|
2875 |
if (!listEquals(this.innerClasses, other.innerClasses)) { |
|
2876 |
return false; |
|
2877 |
} |
|
2878 |
return true; |
|
2879 |
} |
|
2880 |
||
2881 |
protected void writeInnerClasses(Appendable output, |
|
2882 |
String baselineVersion, |
|
2883 |
String version) throws IOException { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2884 |
if (innerClasses != null && !innerClasses.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2885 |
for (InnerClassInfo ici : innerClasses) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2886 |
output.append("innerclass"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2887 |
output.append(" innerClass " + ici.innerClass); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2888 |
output.append(" outerClass " + ici.outerClass); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2889 |
output.append(" innerClassName " + ici.innerClassName); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2890 |
output.append(" flags " + Integer.toHexString(ici.innerClassFlags)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2891 |
output.append("\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2892 |
} |
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 |
|
47703 | 2896 |
protected void readInnerClasses(LineBasedReader reader) throws IOException { |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2897 |
innerClasses = new ArrayList<>(); |
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 |
while ("innerclass".equals(reader.lineKey)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2900 |
InnerClassInfo info = new InnerClassInfo(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2901 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2902 |
info.innerClass = reader.attributes.get("innerClass"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2903 |
info.outerClass = reader.attributes.get("outerClass"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2904 |
info.innerClassName = reader.attributes.get("innerClassName"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2905 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2906 |
String inFlags = reader.attributes.get("flags"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2907 |
if (inFlags != null && !inFlags.isEmpty()) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2908 |
info.innerClassFlags = Integer.parseInt(inFlags, 16); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2909 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2910 |
innerClasses.add(info); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2911 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2912 |
reader.moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2913 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2914 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2915 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2916 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2917 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2918 |
static class MethodDescription extends FeatureDescription { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2919 |
String name; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2920 |
String descriptor; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2921 |
List<String> thrownTypes; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2922 |
Object annotationDefaultValue; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2923 |
List<List<AnnotationDescription>> classParameterAnnotations; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2924 |
List<List<AnnotationDescription>> runtimeParameterAnnotations; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2925 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2926 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2927 |
public int hashCode() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2928 |
int hash = super.hashCode(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2929 |
hash = 59 * hash + Objects.hashCode(this.name); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2930 |
hash = 59 * hash + Objects.hashCode(this.descriptor); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2931 |
hash = 59 * hash + Objects.hashCode(this.thrownTypes); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2932 |
hash = 59 * hash + Objects.hashCode(this.annotationDefaultValue); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2933 |
return hash; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2934 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2935 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2936 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2937 |
public boolean equals(Object obj) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2938 |
if (obj == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2939 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2940 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2941 |
if (!super.equals(obj)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2942 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2943 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2944 |
final MethodDescription other = (MethodDescription) obj; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2945 |
if (!Objects.equals(this.name, other.name)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2946 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2947 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2948 |
if (!Objects.equals(this.descriptor, other.descriptor)) { |
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 (!Objects.equals(this.thrownTypes, other.thrownTypes)) { |
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 |
if (!Objects.equals(this.annotationDefaultValue, other.annotationDefaultValue)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2955 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2956 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2957 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2958 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2959 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2960 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2961 |
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
|
2962 |
if (shouldIgnore(baselineVersion, version)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2963 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2964 |
if (!versions.contains(version)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2965 |
output.append("-method"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2966 |
output.append(" name " + quote(name, false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2967 |
output.append(" descriptor " + quote(descriptor, false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2968 |
output.append("\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2969 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2970 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2971 |
output.append("method"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2972 |
output.append(" name " + quote(name, false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2973 |
output.append(" descriptor " + quote(descriptor, false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2974 |
if (thrownTypes != null) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2975 |
output.append(" thrownTypes " + serializeList(thrownTypes)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2976 |
if (annotationDefaultValue != null) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2977 |
output.append(" annotationDefaultValue " + quote(AnnotationDescription.dumpAnnotationValue(annotationDefaultValue), false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2978 |
writeAttributes(output); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2979 |
if (classParameterAnnotations != null && !classParameterAnnotations.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2980 |
output.append(" classParameterAnnotations "); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2981 |
for (List<AnnotationDescription> pa : classParameterAnnotations) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2982 |
for (AnnotationDescription a : pa) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2983 |
output.append(quote(a.toString(), false)); |
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 |
output.append(";"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2986 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2987 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2988 |
if (runtimeParameterAnnotations != null && !runtimeParameterAnnotations.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2989 |
output.append(" runtimeParameterAnnotations "); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2990 |
for (List<AnnotationDescription> pa : runtimeParameterAnnotations) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2991 |
for (AnnotationDescription a : pa) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2992 |
output.append(quote(a.toString(), false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2993 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2994 |
output.append(";"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
2995 |
} |
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 |
output.append("\n"); |
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 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3001 |
public boolean read(LineBasedReader reader) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3002 |
if (!"method".equals(reader.lineKey)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3003 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3004 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3005 |
name = reader.attributes.get("name"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3006 |
descriptor = reader.attributes.get("descriptor"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3007 |
|
50027 | 3008 |
String thrownTypesValue = reader.attributes.get("thrownTypes"); |
3009 |
||
3010 |
if (thrownTypesValue != null) { |
|
3011 |
thrownTypes = deserializeList(thrownTypesValue); |
|
3012 |
} |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3013 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3014 |
String inAnnotationDefaultValue = reader.attributes.get("annotationDefaultValue"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3015 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3016 |
if (inAnnotationDefaultValue != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3017 |
annotationDefaultValue = parseAnnotationValue(inAnnotationDefaultValue, new int[1]); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3018 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3019 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3020 |
readAttributes(reader); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3021 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3022 |
String inClassParamAnnotations = reader.attributes.get("classParameterAnnotations"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3023 |
if (inClassParamAnnotations != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3024 |
List<List<AnnotationDescription>> annos = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3025 |
int[] pointer = new int[1]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3026 |
do { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3027 |
annos.add(parseAnnotations(inClassParamAnnotations, pointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3028 |
assert pointer[0] == inClassParamAnnotations.length() || inClassParamAnnotations.charAt(pointer[0]) == ';'; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3029 |
} while (++pointer[0] < inClassParamAnnotations.length()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3030 |
classParameterAnnotations = annos; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3031 |
} |
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 |
String inRuntimeParamAnnotations = reader.attributes.get("runtimeParameterAnnotations"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3034 |
if (inRuntimeParamAnnotations != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3035 |
List<List<AnnotationDescription>> annos = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3036 |
int[] pointer = new int[1]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3037 |
do { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3038 |
annos.add(parseAnnotations(inRuntimeParamAnnotations, pointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3039 |
assert pointer[0] == inRuntimeParamAnnotations.length() || inRuntimeParamAnnotations.charAt(pointer[0]) == ';'; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3040 |
} while (++pointer[0] < inRuntimeParamAnnotations.length()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3041 |
runtimeParameterAnnotations = annos; |
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 |
reader.moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3045 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3046 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3047 |
} |
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 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3050 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3051 |
static class FieldDescription extends FeatureDescription { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3052 |
String name; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3053 |
String descriptor; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3054 |
Object constantValue; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3055 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3056 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3057 |
public int hashCode() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3058 |
int hash = super.hashCode(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3059 |
hash = 59 * hash + Objects.hashCode(this.name); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3060 |
hash = 59 * hash + Objects.hashCode(this.descriptor); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3061 |
hash = 59 * hash + Objects.hashCode(this.constantValue); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3062 |
return hash; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3063 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3064 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3065 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3066 |
public boolean equals(Object obj) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3067 |
if (obj == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3068 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3069 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3070 |
if (!super.equals(obj)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3071 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3072 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3073 |
final FieldDescription other = (FieldDescription) obj; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3074 |
if (!Objects.equals(this.name, other.name)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3075 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3076 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3077 |
if (!Objects.equals(this.descriptor, other.descriptor)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3078 |
return false; |
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 (!Objects.equals(this.constantValue, other.constantValue)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3081 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3082 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3083 |
return true; |
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 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3087 |
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
|
3088 |
if (shouldIgnore(baselineVersion, version)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3089 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3090 |
if (!versions.contains(version)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3091 |
output.append("-field"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3092 |
output.append(" name " + quote(name, false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3093 |
output.append(" descriptor " + quote(descriptor, false)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3094 |
output.append("\n"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3095 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3096 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3097 |
output.append("field"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3098 |
output.append(" name " + name); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3099 |
output.append(" descriptor " + descriptor); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3100 |
if (constantValue != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3101 |
output.append(" constantValue " + quote(constantValue.toString(), false)); |
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 |
writeAttributes(output); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3104 |
output.append("\n"); |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3107 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3108 |
public boolean read(LineBasedReader reader) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3109 |
if (!"field".equals(reader.lineKey)) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3110 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3111 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3112 |
name = reader.attributes.get("name"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3113 |
descriptor = reader.attributes.get("descriptor"); |
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 |
String inConstantValue = reader.attributes.get("constantValue"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3116 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3117 |
if (inConstantValue != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3118 |
switch (descriptor) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3119 |
case "Z": constantValue = "true".equals(inConstantValue); break; |
50027 | 3120 |
case "B": constantValue = Integer.parseInt(inConstantValue); break; |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3121 |
case "C": constantValue = inConstantValue.charAt(0); break; |
50027 | 3122 |
case "S": constantValue = Integer.parseInt(inConstantValue); break; |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3123 |
case "I": constantValue = Integer.parseInt(inConstantValue); break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3124 |
case "J": constantValue = Long.parseLong(inConstantValue); break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3125 |
case "F": constantValue = Float.parseFloat(inConstantValue); break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3126 |
case "D": constantValue = Double.parseDouble(inConstantValue); break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3127 |
case "Ljava/lang/String;": constantValue = inConstantValue; break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3128 |
default: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3129 |
throw new IllegalStateException("Unrecognized field type: " + descriptor); |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3133 |
readAttributes(reader); |
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 |
reader.moveNext(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3136 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3137 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3138 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3139 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3140 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3141 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3142 |
static final class AnnotationDescription { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3143 |
String annotationType; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3144 |
Map<String, Object> values; |
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 |
public AnnotationDescription(String annotationType, Map<String, Object> values) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3147 |
this.annotationType = annotationType; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3148 |
this.values = values; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3149 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3150 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3151 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3152 |
public int hashCode() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3153 |
int hash = 7; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3154 |
hash = 47 * hash + Objects.hashCode(this.annotationType); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3155 |
hash = 47 * hash + Objects.hashCode(this.values); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3156 |
return hash; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3157 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3158 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3159 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3160 |
public boolean equals(Object obj) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3161 |
if (obj == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3162 |
return false; |
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 |
if (getClass() != obj.getClass()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3165 |
return false; |
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 |
final AnnotationDescription other = (AnnotationDescription) obj; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3168 |
if (!Objects.equals(this.annotationType, other.annotationType)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3169 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3170 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3171 |
if (!Objects.equals(this.values, other.values)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3172 |
return false; |
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 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3175 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3176 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3177 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3178 |
public String toString() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3179 |
StringBuilder result = new StringBuilder(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3180 |
result.append("@" + annotationType); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3181 |
if (!values.isEmpty()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3182 |
result.append("("); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3183 |
boolean first = true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3184 |
for (Entry<String, Object> e : values.entrySet()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3185 |
if (!first) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3186 |
result.append(","); |
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 |
first = false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3189 |
result.append(e.getKey()); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3190 |
result.append("="); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3191 |
result.append(dumpAnnotationValue(e.getValue())); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3192 |
result.append(""); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3193 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3194 |
result.append(")"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3195 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3196 |
return result.toString(); |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3199 |
private static String dumpAnnotationValue(Object value) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3200 |
if (value instanceof List) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3201 |
StringBuilder result = new StringBuilder(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3202 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3203 |
result.append("{"); |
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 |
for (Object element : ((List) value)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3206 |
result.append(dumpAnnotationValue(element)); |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3209 |
result.append("}"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3210 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3211 |
return result.toString(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3212 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3213 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3214 |
if (value instanceof String) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3215 |
return "\"" + quote((String) value, true) + "\""; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3216 |
} else if (value instanceof Boolean) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3217 |
return "Z" + value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3218 |
} else if (value instanceof Byte) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3219 |
return "B" + value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3220 |
} if (value instanceof Character) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3221 |
return "C" + value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3222 |
} if (value instanceof Short) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3223 |
return "S" + value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3224 |
} if (value instanceof Integer) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3225 |
return "I" + value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3226 |
} if (value instanceof Long) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3227 |
return "J" + value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3228 |
} if (value instanceof Float) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3229 |
return "F" + value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3230 |
} if (value instanceof Double) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3231 |
return "D" + value; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3232 |
} else { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3233 |
return value.toString(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3234 |
} |
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 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3237 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3238 |
static final class EnumConstant { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3239 |
String type; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3240 |
String constant; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3241 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3242 |
public EnumConstant(String type, String constant) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3243 |
this.type = type; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3244 |
this.constant = constant; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3245 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3246 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3247 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3248 |
public String toString() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3249 |
return "e" + type + constant + ";"; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3250 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3251 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3252 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3253 |
public int hashCode() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3254 |
int hash = 7; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3255 |
hash = 19 * hash + Objects.hashCode(this.type); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3256 |
hash = 19 * hash + Objects.hashCode(this.constant); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3257 |
return hash; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3258 |
} |
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 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3261 |
public boolean equals(Object obj) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3262 |
if (obj == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3263 |
return false; |
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 (getClass() != obj.getClass()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3266 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3267 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3268 |
final EnumConstant other = (EnumConstant) obj; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3269 |
if (!Objects.equals(this.type, other.type)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3270 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3271 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3272 |
if (!Objects.equals(this.constant, other.constant)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3273 |
return false; |
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 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3276 |
} |
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 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3280 |
static final class ClassConstant { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3281 |
String type; |
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 |
public ClassConstant(String type) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3284 |
this.type = type; |
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 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3288 |
public String toString() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3289 |
return "c" + type; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3290 |
} |
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 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3293 |
public int hashCode() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3294 |
int hash = 3; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3295 |
hash = 53 * hash + Objects.hashCode(this.type); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3296 |
return hash; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3297 |
} |
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 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3300 |
public boolean equals(Object obj) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3301 |
if (obj == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3302 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3303 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3304 |
if (getClass() != obj.getClass()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3305 |
return false; |
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 |
final ClassConstant other = (ClassConstant) obj; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3308 |
if (!Objects.equals(this.type, other.type)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3309 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3310 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3311 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3312 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3313 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3314 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3315 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3316 |
static final class InnerClassInfo { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3317 |
String innerClass; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3318 |
String outerClass; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3319 |
String innerClassName; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3320 |
int innerClassFlags; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3321 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3322 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3323 |
public int hashCode() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3324 |
int hash = 3; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3325 |
hash = 11 * hash + Objects.hashCode(this.innerClass); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3326 |
hash = 11 * hash + Objects.hashCode(this.outerClass); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3327 |
hash = 11 * hash + Objects.hashCode(this.innerClassName); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3328 |
hash = 11 * hash + Objects.hashCode(this.innerClassFlags); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3329 |
return hash; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3330 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3331 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3332 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3333 |
public boolean equals(Object obj) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3334 |
if (obj == null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3335 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3336 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3337 |
if (getClass() != obj.getClass()) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3338 |
return false; |
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 |
final InnerClassInfo other = (InnerClassInfo) obj; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3341 |
if (!Objects.equals(this.innerClass, other.innerClass)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3342 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3343 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3344 |
if (!Objects.equals(this.outerClass, other.outerClass)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3345 |
return false; |
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 |
if (!Objects.equals(this.innerClassName, other.innerClassName)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3348 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3349 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3350 |
if (!Objects.equals(this.innerClassFlags, other.innerClassFlags)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3351 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3352 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3353 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3354 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3355 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3356 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3357 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3358 |
public static final class ClassList implements Iterable<ClassDescription> { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3359 |
private final List<ClassDescription> classes = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3360 |
private final Map<String, ClassDescription> name2Class = new HashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3361 |
private final Map<ClassDescription, ClassDescription> inner2Outter = new HashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3362 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3363 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3364 |
public Iterator<ClassDescription> iterator() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3365 |
return classes.iterator(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3366 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3367 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3368 |
public void add(ClassDescription desc) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3369 |
classes.add(desc); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3370 |
name2Class.put(desc.name, desc); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3371 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3372 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3373 |
public ClassDescription find(String name) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3374 |
return find(name, ALLOW_NON_EXISTING_CLASSES); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3375 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3376 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3377 |
public ClassDescription find(String name, boolean allowNull) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3378 |
ClassDescription desc = name2Class.get(name); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3379 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3380 |
if (desc != null || allowNull) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3381 |
return desc; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3382 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3383 |
throw new IllegalStateException("Cannot find: " + name); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3384 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3385 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3386 |
private static final ClassDescription NONE = new ClassDescription(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3387 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3388 |
public ClassDescription enclosingClass(ClassDescription clazz) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3389 |
if (clazz == null) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3390 |
return null; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3391 |
ClassDescription desc = inner2Outter.computeIfAbsent(clazz, c -> { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3392 |
ClassHeaderDescription header = clazz.header.get(0); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3393 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3394 |
if (header.innerClasses != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3395 |
for (InnerClassInfo ici : header.innerClasses) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3396 |
if (ici.innerClass.equals(clazz.name)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3397 |
return find(ici.outerClass); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3398 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3399 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3400 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3401 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3402 |
return NONE; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3403 |
}); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3404 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3405 |
return desc != NONE ? desc : null; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3406 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3407 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3408 |
public Iterable<ClassDescription> enclosingClasses(ClassDescription clazz) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3409 |
List<ClassDescription> result = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3410 |
ClassDescription outer = enclosingClass(clazz); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3411 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3412 |
while (outer != null) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3413 |
result.add(outer); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3414 |
outer = enclosingClass(outer); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3415 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3416 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3417 |
return result; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3418 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3419 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3420 |
public void sort() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3421 |
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
|
3422 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3423 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3424 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3425 |
private static int listHashCode(Collection<?> c) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3426 |
return c == null || c.isEmpty() ? 0 : c.hashCode(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3427 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3428 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3429 |
private static boolean listEquals(Collection<?> c1, Collection<?> c2) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3430 |
if (c1 == c2) return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3431 |
if (c1 == null && c2.isEmpty()) return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3432 |
if (c2 == null && c1.isEmpty()) return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3433 |
return Objects.equals(c1, c2); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3434 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3435 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3436 |
private static String serializeList(List<String> list) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3437 |
StringBuilder result = new StringBuilder(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3438 |
String sep = ""; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3439 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3440 |
for (Object o : list) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3441 |
result.append(sep); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3442 |
result.append(o); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3443 |
sep = ","; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3444 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3445 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3446 |
return quote(result.toString(), false); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3447 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3448 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3449 |
private static List<String> deserializeList(String serialized) { |
47703 | 3450 |
return deserializeList(serialized, true); |
3451 |
} |
|
3452 |
||
3453 |
private static List<String> deserializeList(String serialized, |
|
3454 |
boolean unquote) { |
|
3455 |
serialized = unquote ? unquote(serialized) : serialized; |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3456 |
if (serialized == null) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3457 |
return new ArrayList<>(); |
50027 | 3458 |
return new ArrayList<>(List.of(serialized.split(","))); |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3459 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3460 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3461 |
private static String quote(String value, boolean quoteQuotes) { |
47703 | 3462 |
return quote(value, quoteQuotes, false); |
3463 |
} |
|
3464 |
||
3465 |
private static String quote(String value, boolean quoteQuotes, |
|
3466 |
boolean quoteCommas) { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3467 |
StringBuilder result = new StringBuilder(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3468 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3469 |
for (char c : value.toCharArray()) { |
47703 | 3470 |
if (c <= 32 || c >= 127 || c == '\\' || |
3471 |
(quoteQuotes && c == '"') || (quoteCommas && c == ',')) { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3472 |
result.append("\\u" + String.format("%04X", (int) c) + ";"); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3473 |
} else { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3474 |
result.append(c); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3475 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3476 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3477 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3478 |
return result.toString(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3479 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3480 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3481 |
private static final Pattern unicodePattern = |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3482 |
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
|
3483 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3484 |
private static String unquote(String value) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3485 |
if (value == null) |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3486 |
return null; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3487 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3488 |
StringBuilder result = new StringBuilder(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3489 |
Matcher m = unicodePattern.matcher(value); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3490 |
int lastStart = 0; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3491 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3492 |
while (m.find(lastStart)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3493 |
result.append(value.substring(lastStart, m.start())); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3494 |
result.append((char) Integer.parseInt(m.group(1), 16)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3495 |
lastStart = m.end() + 1; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3496 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3497 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3498 |
result.append(value.substring(lastStart, value.length())); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3499 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3500 |
return result.toString(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3501 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3502 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3503 |
private static String readDigits(String value, int[] valuePointer) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3504 |
int start = valuePointer[0]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3505 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3506 |
if (value.charAt(valuePointer[0]) == '-') |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3507 |
valuePointer[0]++; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3508 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3509 |
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
|
3510 |
valuePointer[0]++; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3511 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3512 |
return value.substring(start, valuePointer[0]); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3513 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3514 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3515 |
private static String className(String value, int[] valuePointer) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3516 |
int start = valuePointer[0]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3517 |
while (value.charAt(valuePointer[0]++) != ';') |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3518 |
; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3519 |
return value.substring(start, valuePointer[0]); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3520 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3521 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3522 |
private static Object parseAnnotationValue(String value, int[] valuePointer) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3523 |
switch (value.charAt(valuePointer[0]++)) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3524 |
case 'Z': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3525 |
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
|
3526 |
valuePointer[0] += 4; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3527 |
return true; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3528 |
} 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
|
3529 |
valuePointer[0] += 5; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3530 |
return false; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3531 |
} else { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3532 |
throw new IllegalStateException("Unrecognized boolean structure: " + value); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3533 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3534 |
case 'B': return Byte.parseByte(readDigits(value, valuePointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3535 |
case 'C': return value.charAt(valuePointer[0]++); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3536 |
case 'S': return Short.parseShort(readDigits(value, valuePointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3537 |
case 'I': return Integer.parseInt(readDigits(value, valuePointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3538 |
case 'J': return Long.parseLong(readDigits(value, valuePointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3539 |
case 'F': return Float.parseFloat(readDigits(value, valuePointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3540 |
case 'D': return Double.parseDouble(readDigits(value, valuePointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3541 |
case 'c': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3542 |
return new ClassConstant(className(value, valuePointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3543 |
case 'e': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3544 |
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
|
3545 |
case '{': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3546 |
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
|
3547 |
while (value.charAt(valuePointer[0]) != '}') { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3548 |
elements.add(parseAnnotationValue(value, valuePointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3549 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3550 |
valuePointer[0]++; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3551 |
return elements; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3552 |
case '"': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3553 |
int start = valuePointer[0]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3554 |
while (value.charAt(valuePointer[0]) != '"') |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3555 |
valuePointer[0]++; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3556 |
return unquote(value.substring(start, valuePointer[0]++)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3557 |
case '@': |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3558 |
return parseAnnotation(value, valuePointer); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3559 |
default: |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3560 |
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
|
3561 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3562 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3563 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3564 |
public static List<AnnotationDescription> parseAnnotations(String encoded, int[] pointer) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3565 |
ArrayList<AnnotationDescription> result = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3566 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3567 |
while (pointer[0] < encoded.length() && encoded.charAt(pointer[0]) == '@') { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3568 |
pointer[0]++; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3569 |
result.add(parseAnnotation(encoded, pointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3570 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3571 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3572 |
return result; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3573 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3574 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3575 |
private static AnnotationDescription parseAnnotation(String value, int[] valuePointer) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3576 |
String className = className(value, valuePointer); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3577 |
Map<String, Object> attribute2Value = new HashMap<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3578 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3579 |
if (valuePointer[0] < value.length() && value.charAt(valuePointer[0]) == '(') { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3580 |
while (value.charAt(valuePointer[0]) != ')') { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3581 |
int nameStart = ++valuePointer[0]; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3582 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3583 |
while (value.charAt(valuePointer[0]++) != '='); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3584 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3585 |
String name = value.substring(nameStart, valuePointer[0] - 1); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3586 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3587 |
attribute2Value.put(name, parseAnnotationValue(value, valuePointer)); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3588 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3589 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3590 |
valuePointer[0]++; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3591 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3592 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3593 |
return new AnnotationDescription(className, attribute2Value); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3594 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3595 |
//</editor-fold> |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3596 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3597 |
private static void help() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3598 |
System.err.println("Help..."); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3599 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3600 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3601 |
public static void main(String... args) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3602 |
if (args.length < 1) { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3603 |
help(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3604 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3605 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3606 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3607 |
switch (args[0]) { |
50027 | 3608 |
case "build-description": { |
47703 | 3609 |
if (args.length < 3) { |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3610 |
help(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3611 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3612 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3613 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3614 |
Path descDest = Paths.get(args[1]); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3615 |
List<VersionDescription> versions = new ArrayList<>(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3616 |
|
47703 | 3617 |
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
|
3618 |
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
|
3619 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3620 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3621 |
Files.walkFileTree(descDest, new FileVisitor<Path>() { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3622 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3623 |
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3624 |
return FileVisitResult.CONTINUE; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3625 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3626 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3627 |
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3628 |
Files.delete(file); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3629 |
return FileVisitResult.CONTINUE; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3630 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3631 |
@Override |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3632 |
public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException { |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3633 |
return FileVisitResult.CONTINUE; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3634 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3635 |
@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
|
3636 |
Files.delete(dir); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3637 |
return FileVisitResult.CONTINUE; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3638 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3639 |
}); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3640 |
|
47703 | 3641 |
ExcludeIncludeList excludeList = |
3642 |
ExcludeIncludeList.create(args[2]); |
|
3643 |
||
3644 |
new CreateSymbols().createBaseLine(versions, |
|
3645 |
excludeList, |
|
3646 |
descDest, |
|
3647 |
args); |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3648 |
break; |
50027 | 3649 |
} |
3650 |
case "build-description-incremental": { |
|
3651 |
if (args.length != 3) { |
|
3652 |
help(); |
|
3653 |
return ; |
|
3654 |
} |
|
3655 |
||
3656 |
new CreateSymbols().createIncrementalBaseLine(args[1], args[2], args); |
|
3657 |
break; |
|
3658 |
} |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3659 |
case "build-ctsym": |
51799 | 3660 |
String ctDescriptionFileExtra; |
3661 |
String ctDescriptionFile; |
|
3662 |
String ctSymLocation; |
|
3663 |
||
3664 |
if (args.length == 3) { |
|
3665 |
ctDescriptionFileExtra = null; |
|
3666 |
ctDescriptionFile = args[1]; |
|
3667 |
ctSymLocation = args[2]; |
|
3668 |
} else if (args.length == 4) { |
|
3669 |
ctDescriptionFileExtra = args[1]; |
|
3670 |
ctDescriptionFile = args[2]; |
|
3671 |
ctSymLocation = args[3]; |
|
3672 |
} else { |
|
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3673 |
help(); |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3674 |
return ; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3675 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3676 |
|
51799 | 3677 |
new CreateSymbols().createSymbols(ctDescriptionFileExtra, |
3678 |
ctDescriptionFile, |
|
51832
bf1d479fe7eb
8209865: Incorrect 'multiple elements' notes with Elements#getTypeElement and --release
jlahoda
parents:
51799
diff
changeset
|
3679 |
ctSymLocation); |
31506
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3680 |
break; |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3681 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3682 |
} |
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3683 |
|
4e07f827a794
8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff
changeset
|
3684 |
} |