make/langtools/src/classes/build/tools/symbolgenerator/CreateSymbols.java
author ihse
Mon, 03 Dec 2018 18:33:11 +0100
branchihse-manpages-branch
changeset 57051 d8697832a650
parent 51832 bf1d479fe7eb
child 53696 f0f8f0afed74
permissions -rw-r--r--
Add html filter script from Jon.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31506
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff changeset
     1
/*
50027
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
     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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
    28
import build.tools.symbolgenerator.CreateSymbols
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
    29
                                  .ModuleHeaderDescription
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
    30
                                  .ProvidesDescription;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
    31
import build.tools.symbolgenerator.CreateSymbols
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
    32
                                  .ModuleHeaderDescription
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
    33
                                  .RequiresDescription;
50027
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
    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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
    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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
    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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
    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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
    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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
    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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
    74
import javax.tools.JavaFileManager;
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
    75
import javax.tools.JavaFileManager.Location;
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
    76
import javax.tools.JavaFileObject;
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
    77
import javax.tools.JavaFileObject.Kind;
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
    78
import javax.tools.StandardLocation;
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
    79
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
    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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   101
import com.sun.tools.classfile.ConstantPool.CONSTANT_Module_info;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   116
import com.sun.tools.classfile.ModuleResolution_attribute;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   117
import com.sun.tools.classfile.ModuleTarget_attribute;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   118
import com.sun.tools.classfile.Module_attribute;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   119
import com.sun.tools.classfile.Module_attribute.ExportsEntry;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   120
import com.sun.tools.classfile.Module_attribute.OpensEntry;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   121
import com.sun.tools.classfile.Module_attribute.ProvidesEntry;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   122
import com.sun.tools.classfile.Module_attribute.RequiresEntry;
51799
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   123
import com.sun.tools.classfile.NestHost_attribute;
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   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
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   139
 * A tool for processing the .sym.txt files.
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   140
 *
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   141
 * To add historical data for JDK N, N >= 11, do the following:
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   142
 *  * cd <open-jdk-checkout>/make/data/symbols
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   143
 *  * <jdk-N>/bin/java --add-exports jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED \
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   144
 *                     --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   145
 *                     --add-exports jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED \
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   146
 *                     --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED \
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   147
 *                     --add-modules jdk.jdeps \
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   148
 *                     ../../../make/langtools/src/classes/build/tools/symbolgenerator/CreateSymbols.java \
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   149
 *                     build-description-incremental symbols include.list
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   150
 *  * sanity-check the new and updates files in make/data/symbols and commit them
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   151
 *
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   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
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   213
        LoadDescriptions data = load(ctDescriptionFileExtra != null ? Paths.get(ctDescriptionFileExtra)
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   214
                                                                    : null,
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   215
                                     Paths.get(ctDescriptionFile), null);
50027
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   216
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   217
        splitHeaders(data.classes);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   221
        for (ModuleDescription md : data.modules.values()) {
47703
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   222
            for (ModuleHeaderDescription mhd : md.header) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   223
                List<String> versionsList =
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   224
                        Collections.singletonList(mhd.versions);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   225
                writeModulesForVersions(ctSymLocation,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   226
                                        md,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   227
                                        mhd,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   234
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   235
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   236
50027
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   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
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   271
    LoadDescriptions load(Path ctDescriptionWithExtraContent, Path ctDescriptionOpen, String deletePlatform) throws IOException {
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   272
        Map<String, PlatformInput> platforms = new LinkedHashMap<>();
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   273
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   274
        if (ctDescriptionWithExtraContent != null && Files.isRegularFile(ctDescriptionWithExtraContent)) {
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   275
            try (LineBasedReader reader = new LineBasedReader(ctDescriptionWithExtraContent)) {
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   276
                while (reader.hasNext()) {
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   277
                    switch (reader.lineKey) {
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   278
                        case "generate":
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   279
                            //ignore
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   280
                            reader.moveNext();
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   281
                            break;
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   282
                        case "platform":
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   283
                            PlatformInput platform = PlatformInput.load(ctDescriptionWithExtraContent,
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   284
                                                                        reader);
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   285
                            if (!platform.version.equals(deletePlatform))
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   286
                                platforms.put(platform.version, platform);
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   287
                            reader.moveNext();
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   288
                            break;
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   289
                        default:
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   290
                            throw new IllegalStateException("Unknown key: " + reader.lineKey);
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   291
                    }
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   292
                }
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   293
            }
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   294
        }
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   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
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   303
                        generatePlatforms = new HashSet<>(List.of(platformsAttr));
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   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
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   308
                        PlatformInput platform = PlatformInput.load(ctDescriptionOpen, reader);
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   309
                        if (!platform.version.equals(deletePlatform) &&
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   310
                            !platforms.containsKey(platform.version))
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   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
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   329
            for (ModuleDescription md : modules.values()) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   330
                addNewVersion(md.header, platform.basePlatform, platform.version);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   331
            }
31506
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff changeset
   332
            for (String input : platform.files) {
51799
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   337
                        switch (reader.lineKey) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   338
                            case "class": case "-class":
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   339
                                ClassDescription cd =
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   340
                                        classes.computeIfAbsent(nameAttr,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   341
                                                n -> new ClassDescription());
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   342
                                if ("-class".equals(reader.lineKey)) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   343
                                    removeVersion(cd.header, h -> true,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   344
                                                  platform.version);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   345
                                    reader.moveNext();
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   346
                                    continue;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   347
                                }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   348
                                cd.read(reader, platform.basePlatform,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   349
                                        platform.version);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   350
                                break;
50027
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   351
                            case "module": {
47703
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   352
                                ModuleDescription md =
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   353
                                        modules.computeIfAbsent(nameAttr,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   354
                                                n -> new ModuleDescription());
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   355
                                md.read(reader, platform.basePlatform,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   356
                                        platform.version);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   357
                                break;
50027
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   358
                            }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   359
                            case "-module": {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   360
                                ModuleDescription md =
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   361
                                        modules.computeIfAbsent(nameAttr,
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   362
                                                n -> new ModuleDescription());
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   363
                                removeVersion(md.header, h -> true,
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   364
                                              platform.version);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   365
                                reader.moveNext();
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   366
                                break;
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   377
            Iterator<ClassHeaderDescription> chdIt = desc.header.iterator();
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   378
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   391
            Iterator<MethodDescription> methodIt = desc.methods.iterator();
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   392
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   401
            Iterator<FieldDescription> fieldIt = desc.fields.iterator();
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   402
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   414
        Map<String, ModuleDescription> moduleList = new HashMap<>();
47703
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   415
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   416
        for (ModuleDescription desc : modules.values()) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   417
            Iterator<ModuleHeaderDescription> mhdIt = desc.header.iterator();
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   418
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   419
            while (mhdIt.hasNext()) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   420
                ModuleHeaderDescription mhd = mhdIt.next();
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   421
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   422
                mhd.versions = reduce(mhd.versions, generatePlatforms);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   423
                if (mhd.versions.isEmpty())
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   424
                    mhdIt.remove();
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   425
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   426
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   427
            if (desc.header.isEmpty()) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   428
                continue;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   429
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   430
50027
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   431
            moduleList.put(desc.name, desc);
47703
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   432
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   433
51799
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   434
        return new LoadDescriptions(result, moduleList, new ArrayList<>(platforms.values()));
50027
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   435
    }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   436
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   437
    static final class LoadDescriptions {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   438
        public final ClassList classes;
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   439
        public final Map<String, ModuleDescription> modules;
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   440
        public final List<PlatformInput> versions;
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   441
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   442
        public LoadDescriptions(ClassList classes,
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   443
                                Map<String, ModuleDescription>  modules,
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   444
                                List<PlatformInput> versions) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   445
            this.classes = classes;
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   446
            this.modules = modules;
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   447
            this.versions = versions;
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   448
        }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   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
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   520
        public final Path ctDescription;
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   521
        public PlatformInput(Path ctDescription, String version, String basePlatform, List<String> files) {
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   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
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   528
        public static PlatformInput load(Path ctDescription, LineBasedReader in) throws IOException {
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   529
            return new PlatformInput(ctDescription,
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   671
                                 Iterable<String> versions)
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   678
    void writeModulesForVersions(String ctSymLocation,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   679
                                 ModuleDescription moduleDescription,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   680
                                 ModuleHeaderDescription header,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   681
                                 Iterable<String> versions)
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   682
            throws IOException {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   683
        for (String ver : versions) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   684
            writeModule(ctSymLocation, moduleDescription, header, ver);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   685
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   686
    }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   689
    void writeModule(String ctSymLocation,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   690
                    ModuleDescription moduleDescription,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   691
                    ModuleHeaderDescription header,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   692
                    String version) throws IOException {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   693
        List<CPInfo> constantPool = new ArrayList<>();
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   694
        constantPool.add(null);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   695
        int currentClass = addClass(constantPool, "module-info");
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   696
        int superclass = 0;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   697
        int[] interfaces = new int[0];
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   698
        AccessFlags flags = new AccessFlags(header.flags);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   699
        Map<String, Attribute> attributesMap = new HashMap<>();
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   700
        addAttributes(moduleDescription, header, constantPool, attributesMap);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   701
        Attributes attributes = new Attributes(attributesMap);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   702
        CPInfo[] cpData = constantPool.toArray(new CPInfo[constantPool.size()]);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   703
        ConstantPool cp = new ConstantPool(cpData);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   704
        ClassFile classFile = new ClassFile(0xCAFEBABE,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   705
                Target.DEFAULT.minorVersion,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   706
                Target.DEFAULT.majorVersion,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   707
                cp,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   708
                flags,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   709
                currentClass,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   710
                superclass,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   711
                interfaces,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   712
                new Field[0],
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   713
                new Method[0],
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   714
                attributes);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   715
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   718
                                         moduleDescription.name,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   719
                                         "module-info" + EXTENSION);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   720
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   721
        Files.createDirectories(outputClassFile.getParent());
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   722
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   723
        try (OutputStream out = Files.newOutputStream(outputClassFile)) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   724
            ClassWriter w = new ClassWriter();
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   725
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   726
            w.write(classFile, out);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   727
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   728
    }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   803
    private void addAttributes(ModuleDescription md,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   804
                               ModuleHeaderDescription header,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   805
                               List<CPInfo> cp,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   806
                               Map<String, Attribute> attributes) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   807
        addGenericAttributes(header, cp, attributes);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   808
        if (header.moduleResolution != null) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   809
            int attrIdx = addString(cp, Attribute.ModuleResolution);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   810
            final ModuleResolution_attribute resIdx =
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   811
                    new ModuleResolution_attribute(attrIdx,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   812
                                                   header.moduleResolution);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   813
            attributes.put(Attribute.ModuleResolution, resIdx);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   814
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   815
        if (header.moduleTarget != null) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   816
            int attrIdx = addString(cp, Attribute.ModuleTarget);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   817
            int targetIdx = addString(cp, header.moduleTarget);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   818
            attributes.put(Attribute.ModuleTarget,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   819
                           new ModuleTarget_attribute(attrIdx, targetIdx));
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   820
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   821
        int attrIdx = addString(cp, Attribute.Module);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   822
        attributes.put(Attribute.Module,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   823
                       new Module_attribute(attrIdx,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   824
                             addModuleName(cp, md.name),
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   825
                             0,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   826
                             0,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   827
                             header.requires
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   828
                                   .stream()
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   829
                                   .map(r -> createRequiresEntry(cp, r))
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   830
                                   .collect(Collectors.toList())
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   831
                                   .toArray(new RequiresEntry[0]),
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   832
                             header.exports
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   833
                                   .stream()
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   834
                                   .map(e -> createExportsEntry(cp, e))
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   835
                                   .collect(Collectors.toList())
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   836
                                   .toArray(new ExportsEntry[0]),
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   837
                             header.opens
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   838
                                   .stream()
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   839
                                   .map(e -> createOpensEntry(cp, e))
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   840
                                   .collect(Collectors.toList())
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   841
                                   .toArray(new OpensEntry[0]),
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   842
                             header.uses
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   843
                                   .stream()
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   844
                                   .mapToInt(u -> addClassName(cp, u))
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   845
                                   .toArray(),
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   846
                             header.provides
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   847
                                   .stream()
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   848
                                   .map(p -> createProvidesEntry(cp, p))
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   849
                                   .collect(Collectors.toList())
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   850
                                   .toArray(new ProvidesEntry[0])));
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   851
        addInnerClassesAttribute(header, cp, attributes);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   852
    }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   853
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   854
    private static RequiresEntry createRequiresEntry(List<CPInfo> cp,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   855
            RequiresDescription r) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   856
        final int idx = addModuleName(cp, r.moduleName);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   857
        return new RequiresEntry(idx,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   858
                                 r.flags,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   859
                                 r.version != null
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   860
                                         ? addInt(cp, r.version)
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   861
                                         : 0);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   862
    }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   863
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   864
    private static ExportsEntry createExportsEntry(List<CPInfo> cp,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   865
                                                   String e) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   866
        return new ExportsEntry(addPackageName(cp, e), 0, new int[0]);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   867
    }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   868
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   869
    private static OpensEntry createOpensEntry(List<CPInfo> cp, String e) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   870
        return new OpensEntry(addPackageName(cp, e), 0, new int[0]);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   871
    }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   872
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   873
    private static ProvidesEntry createProvidesEntry(List<CPInfo> cp,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   874
            ModuleHeaderDescription.ProvidesDescription p) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   875
        final int idx = addClassName(cp, p.interfaceName);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   876
        return new ProvidesEntry(idx, p.implNames
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   877
                                       .stream()
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   878
                                       .mapToInt(i -> addClassName(cp, i))
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   879
                                       .toArray());
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   880
    }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   881
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   882
    private void addAttributes(ClassHeaderDescription header,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   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
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   885
        if (header.nestHost != null) {
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   886
            int attributeString = addString(constantPool, Attribute.NestHost);
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   887
            int nestHost = addClass(constantPool, header.nestHost);
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   888
            attributes.put(Attribute.NestHost,
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   889
                           new NestHost_attribute(attributeString, nestHost));
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   890
        }
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   891
        if (header.nestMembers != null && !header.nestMembers.isEmpty()) {
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   892
            int attributeString = addString(constantPool, Attribute.NestMembers);
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   893
            int[] nestMembers = new int[header.nestMembers.size()];
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   894
            int i = 0;
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   895
            for (String intf : header.nestMembers) {
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   896
                nestMembers[i++] = addClass(constantPool, intf);
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   897
            }
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   898
            attributes.put(Attribute.NestMembers,
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   899
                           new NestMembers_attribute(attributeString, nestMembers));
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
   900
        }
47703
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   901
        addInnerClassesAttribute(header, constantPool, attributes);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   902
    }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   903
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   904
    private void addInnerClassesAttribute(HeaderDescription header,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
   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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
   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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1115
    private static int addInt(List<CPInfo> constantPool, int value) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1116
        int i = 0;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1117
        for (CPInfo info : constantPool) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1118
            if (info instanceof CONSTANT_Integer_info) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1119
                if (((CONSTANT_Integer_info) info).value == value) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1120
                    return i;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1121
                }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1122
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1123
            i++;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1124
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1125
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1126
        return addToCP(constantPool, new CONSTANT_Integer_info(value));
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1127
    }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1128
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1129
    private static int addModuleName(List<CPInfo> constantPool, String moduleName) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1130
        int nameIdx = addString(constantPool, moduleName);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1131
        int i = 0;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1132
        for (CPInfo info : constantPool) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1133
            if (info instanceof CONSTANT_Module_info) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1134
                if (((CONSTANT_Module_info) info).name_index == nameIdx) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1135
                    return i;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1136
                }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1137
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1138
            i++;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1139
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1140
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1141
        return addToCP(constantPool, new CONSTANT_Module_info(null, nameIdx));
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1142
    }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1143
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1144
    private static int addPackageName(List<CPInfo> constantPool, String packageName) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1145
        int nameIdx = addString(constantPool, packageName);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1146
        int i = 0;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1147
        for (CPInfo info : constantPool) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1148
            if (info instanceof CONSTANT_Package_info) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1149
                if (((CONSTANT_Package_info) info).name_index == nameIdx) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1150
                    return i;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1151
                }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1152
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1153
            i++;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1154
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1155
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1156
        return addToCP(constantPool, new CONSTANT_Package_info(null, nameIdx));
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1157
    }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1158
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1159
    private static int addClassName(List<CPInfo> constantPool, String className) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1160
        int nameIdx = addString(constantPool, className);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1161
        int i = 0;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1162
        for (CPInfo info : constantPool) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1163
            if (info instanceof CONSTANT_Class_info) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1164
                if (((CONSTANT_Class_info) info).name_index == nameIdx) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1165
                    return i;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1166
                }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1167
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1168
            i++;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1169
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1170
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1171
        return addToCP(constantPool, new CONSTANT_Class_info(null, nameIdx));
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1172
    }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1205
    public void createBaseLine(List<VersionDescription> versions,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1206
                               ExcludeIncludeList excludesIncludes,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1207
                               Path descDest,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1213
            List<byte[]> classFileData = new ArrayList<>();
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1214
47703
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1215
            try (BufferedReader descIn =
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1216
                    Files.newBufferedReader(Paths.get(desc.classes))) {
50027
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1217
                String line;
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1220
                    for (int i = 0; i < line.length(); i += 2) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1221
                        String hex = line.substring(i, i + 2);
47703
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1222
                        data.write(Integer.parseInt(hex, 16));
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1223
                    }
50027
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1224
                    classFileData.add(data.toByteArray());
47703
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1225
                }
50027
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1226
            } catch (IOException ex) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1227
                throw new IllegalStateException(ex);
47703
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1228
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1229
50027
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1230
            loadVersionClasses(classes, modules, classFileData, excludesIncludes, desc.version);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1231
        }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1232
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1233
        List<PlatformInput> platforms =
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1234
                versions.stream()
51799
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1235
                        .map(desc -> new PlatformInput(null,
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1236
                                                       desc.version,
50027
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1237
                                                       desc.primaryBaseline,
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1238
                                                       null))
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1239
                        .collect(Collectors.toList());
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1240
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1241
        dumpDescriptions(classes, modules, platforms, descDest.resolve("symbols"), args);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1242
    }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1243
    //where:
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1244
        private static final String DO_NO_MODIFY =
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1245
            "#\n" +
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1246
            "# Copyright (c) {YEAR}, Oracle and/or its affiliates. All rights reserved.\n" +
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1247
            "# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.\n" +
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1248
            "#\n" +
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1249
            "# This code is free software; you can redistribute it and/or modify it\n" +
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1250
            "# under the terms of the GNU General Public License version 2 only, as\n" +
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1251
            "# published by the Free Software Foundation.  Oracle designates this\n" +
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1252
            "# particular file as subject to the \"Classpath\" exception as provided\n" +
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1253
            "# by Oracle in the LICENSE file that accompanied this code.\n" +
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1254
            "#\n" +
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1255
            "# This code is distributed in the hope that it will be useful, but WITHOUT\n" +
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1256
            "# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n" +
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1257
            "# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\n" +
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1258
            "# version 2 for more details (a copy is included in the LICENSE file that\n" +
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1259
            "# accompanied this code).\n" +
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1260
            "#\n" +
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1261
            "# You should have received a copy of the GNU General Public License version\n" +
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1262
            "# 2 along with this work; if not, write to the Free Software Foundation,\n" +
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1263
            "# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.\n" +
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1264
            "#\n" +
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1265
            "# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA\n" +
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1266
            "# or visit www.oracle.com if you need additional information or have any\n" +
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1267
            "# questions.\n" +
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1268
            "#\n" +
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1269
            "# ##########################################################\n" +
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1270
            "# ### THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. ###\n" +
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1271
            "# ##########################################################\n" +
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1272
            "#\n";
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1273
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1274
    private void loadVersionClasses(ClassList classes,
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1275
                                    Map<String, ModuleDescription> modules,
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1276
                                    Iterable<byte[]> classData,
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1277
                                    ExcludeIncludeList excludesIncludes,
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1278
                                    String version) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1279
        Map<String, ModuleDescription> currentVersionModules =
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1280
                new HashMap<>();
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1281
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1282
        for (byte[] classFileData : classData) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1283
            try (InputStream in = new ByteArrayInputStream(classFileData)) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1284
                inspectModuleInfoClassFile(in,
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1285
                                           currentVersionModules, version);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1286
            } catch (IOException | ConstantPoolException ex) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1287
                throw new IllegalStateException(ex);
47703
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1288
            }
50027
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1289
        }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1290
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1291
        ExcludeIncludeList currentEIList = excludesIncludes;
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1292
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1293
        if (!currentVersionModules.isEmpty()) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1294
            Set<String> includes = new HashSet<>();
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1295
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1296
            for (ModuleDescription md : currentVersionModules.values()) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1297
                md.header.get(0).exports.stream().map(e -> e + '/')
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1298
                                        .forEach(includes::add);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1299
            }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1300
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1301
            currentEIList = new ExcludeIncludeList(includes,
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1302
                                                   Collections.emptySet());
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1303
        }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1304
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1305
        ClassList currentVersionClasses = new ClassList();
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1306
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1307
        for (byte[] classFileData : classData) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1308
            try (InputStream in = new ByteArrayInputStream(classFileData)) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1309
                inspectClassFile(in, currentVersionClasses,
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1310
                                 currentEIList, version);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1311
            } catch (IOException | ConstantPoolException ex) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1312
                throw new IllegalStateException(ex);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1313
            }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1314
        }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1315
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1316
        ModuleDescription unsupported =
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1317
                currentVersionModules.get("jdk.unsupported");
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1318
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1319
        if (unsupported != null) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1320
            for (ClassDescription cd : currentVersionClasses.classes) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1321
                if (unsupported.header
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1322
                               .get(0)
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1323
                               .exports
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1324
                               .contains(cd.packge().replace('.', '/'))) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1325
                    ClassHeaderDescription ch = cd.header.get(0);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1326
                    if (ch.classAnnotations == null) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1327
                        ch.classAnnotations = new ArrayList<>();
31506
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff changeset
  1328
                    }
50027
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1329
                    AnnotationDescription ad;
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1330
                    ad = new AnnotationDescription(PROPERITARY_ANNOTATION,
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1331
                                                   Collections.emptyMap());
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1332
                    ch.classAnnotations.add(ad);
47703
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1333
                }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1337
        Set<String> includedClasses = new HashSet<>();
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1338
        boolean modified;
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1339
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1340
        do {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1341
            modified = false;
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1342
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1343
            for (ClassDescription clazz : currentVersionClasses) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1344
                ClassHeaderDescription header = clazz.header.get(0);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1345
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1346
                if (includeEffectiveAccess(currentVersionClasses, clazz)) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1347
                    modified |= include(includedClasses, currentVersionClasses, clazz.name);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1348
                }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1349
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1350
                if (includedClasses.contains(clazz.name)) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1351
                    modified |= include(includedClasses, currentVersionClasses, header.extendsAttr);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1352
                    for (String i : header.implementsAttr) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1353
                        modified |= include(includedClasses, currentVersionClasses, i);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1354
                    }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1355
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1356
                    modified |= includeOutputType(Collections.singleton(header),
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1357
                                                  h -> "",
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1358
                                                  includedClasses,
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1359
                                                  currentVersionClasses);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1360
                    modified |= includeOutputType(clazz.fields,
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1361
                                                  f -> f.descriptor,
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1362
                                                  includedClasses,
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1363
                                                  currentVersionClasses);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1364
                    modified |= includeOutputType(clazz.methods,
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1365
                                                  m -> m.descriptor,
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1366
                                                  includedClasses,
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1367
                                                  currentVersionClasses);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1368
                }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1369
            }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1370
        } while (modified);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1371
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1372
        for (ClassDescription clazz : currentVersionClasses) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1373
            if (!includedClasses.contains(clazz.name)) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1374
                continue;
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1375
            }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1376
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1377
            ClassHeaderDescription header = clazz.header.get(0);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1378
51799
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1379
            if (header.nestMembers != null) {
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1380
                Iterator<String> nestMemberIt = header.nestMembers.iterator();
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1381
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1382
                while(nestMemberIt.hasNext()) {
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1383
                    String member = nestMemberIt.next();
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1384
                    if (!includedClasses.contains(member))
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1385
                        nestMemberIt.remove();
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1386
                }
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1387
            }
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1388
50027
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1389
            if (header.innerClasses != null) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1390
                Iterator<InnerClassInfo> innerClassIt = header.innerClasses.iterator();
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1391
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1392
                while(innerClassIt.hasNext()) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1393
                    InnerClassInfo ici = innerClassIt.next();
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1394
                    if (!includedClasses.contains(ici.innerClass))
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1395
                        innerClassIt.remove();
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1396
                }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1397
            }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1398
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1399
            ClassDescription existing = classes.find(clazz.name, true);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1400
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1401
            if (existing != null) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1402
                addClassHeader(existing, header, version);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1403
                for (MethodDescription currentMethod : clazz.methods) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1404
                    addMethod(existing, currentMethod, version);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1405
                }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1406
                for (FieldDescription currentField : clazz.fields) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1407
                    addField(existing, currentField, version);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1408
                }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1409
            } else {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1410
                classes.add(clazz);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1411
            }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1412
        }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1413
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1414
        for (ModuleDescription module : currentVersionModules.values()) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1415
            ModuleHeaderDescription header = module.header.get(0);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1416
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1417
            if (header.innerClasses != null) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1418
                Iterator<InnerClassInfo> innerClassIt =
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1419
                        header.innerClasses.iterator();
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1420
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1421
                while(innerClassIt.hasNext()) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1422
                    InnerClassInfo ici = innerClassIt.next();
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1423
                    if (!includedClasses.contains(ici.innerClass))
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1424
                        innerClassIt.remove();
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1425
                }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1426
            }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1427
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1428
            ModuleDescription existing = modules.get(module.name);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1429
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1430
            if (existing != null) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1431
                addModuleHeader(existing, header, version);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1432
            } else {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1433
                modules.put(module.name, module);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1434
            }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1435
        }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1436
    }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1437
    //where:
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1438
        private static final String PROPERITARY_ANNOTATION =
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1439
                "Lsun/Proprietary+Annotation;";
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1440
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1441
    private void dumpDescriptions(ClassList classes,
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1442
                                  Map<String, ModuleDescription> modules,
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1443
                                  List<PlatformInput> versions,
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1444
                                  Path ctDescriptionFile,
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1448
        Map<String, String> package2Modules = new HashMap<>();
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1449
51799
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1450
        versions.stream()
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1451
                .filter(v -> "9".compareTo(v.version) <= 0)
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1452
                .sorted((v1, v2) -> v1.version.compareTo(v2.version))
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1453
                .forEach(v -> {
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1454
            for (ModuleDescription md : modules.values()) {
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1455
                md.header
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1456
                  .stream()
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1457
                  .filter(h -> h.versions.contains(v.version))
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1458
                  .flatMap(h -> h.exports.stream())
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1459
                  .map(p -> p.replace('/', '.'))
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1460
                  .forEach(p -> package2Modules.putIfAbsent(p, md.name));
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1461
            }
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1462
        });
47703
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1463
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1464
        package2Modules.put("java.awt.dnd.peer", "java.desktop");
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1465
        package2Modules.put("java.awt.peer", "java.desktop");
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1466
        package2Modules.put("jdk", "java.base");
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1494
        modules.keySet()
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1495
               .stream()
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1496
               .filter(m -> !module2Classes.containsKey(m))
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1497
               .forEach(m -> module2Classes.put(m, Collections.emptyList()));
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1498
50027
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1499
        Files.createDirectories(ctDescriptionFile.getParent());
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1500
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1501
        int year = Calendar.getInstance(TimeZone.getTimeZone("UTF"), Locale.ROOT)
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1502
                           .get(Calendar.YEAR);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1503
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1504
        try (Writer symbolsOut = Files.newBufferedWriter(ctDescriptionFile)) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1505
            Map<PlatformInput, List<String>> outputFiles = new LinkedHashMap<>();
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1506
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1507
            for (PlatformInput desc : versions) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1508
                List<String> files = desc.files;
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1509
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1510
                if (files == null) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1511
                    files = new ArrayList<>();
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1512
                    for (Entry<String, List<ClassDescription>> e : module2Classes.entrySet()) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1513
                        StringWriter data = new StringWriter();
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1514
                        ModuleDescription module = modules.get(e.getKey());
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1515
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1516
                        module.write(data, desc.basePlatform, desc.version);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1517
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1518
                        for (ClassDescription clazz : e.getValue()) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1521
50027
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1522
                        String fileName = e.getKey() + "-" + desc.version + ".sym.txt";
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1523
                        Path f = ctDescriptionFile.getParent().resolve(fileName);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1524
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1525
                        String dataString = data.toString();
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1526
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1527
                        if (!dataString.isEmpty()) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1528
                            try (Writer out = Files.newBufferedWriter(f)) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1529
                                out.append(DO_NO_MODIFY.replace("{YEAR}", String.valueOf(year)));
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1530
                                out.write(dataString);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1531
                            }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1532
                            files.add(f.getFileName().toString());
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1536
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1537
                outputFiles.put(desc, files);
31506
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff changeset
  1538
            }
50027
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1539
            symbolsOut.append(DO_NO_MODIFY.replace("{YEAR}", "2015, " + year));
47703
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1540
            symbolsOut.append("#command used to generate this file:\n");
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1541
            symbolsOut.append("#")
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1542
                      .append(CreateSymbols.class.getName())
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1543
                      .append(" ")
50027
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1544
                      .append(Arrays.stream(args)
47703
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1545
                                    .collect(Collectors.joining(" ")))
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1546
                      .append("\n");
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1571
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1572
    public void createIncrementalBaseLine(String ctDescriptionFile,
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1573
                                          String excludeFile,
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1574
                                          String[] args) throws IOException {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1575
        String specVersion = System.getProperty("java.specification.version");
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1576
        String currentVersion =
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1577
                Integer.toString(Integer.parseInt(specVersion), Character.MAX_RADIX);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1578
        currentVersion = currentVersion.toUpperCase(Locale.ROOT);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1579
        Path ctDescriptionPath = Paths.get(ctDescriptionFile).toAbsolutePath();
51799
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1580
        LoadDescriptions data = load(null, ctDescriptionPath, currentVersion);
50027
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1581
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1582
        ClassList classes = data.classes;
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1583
        Map<String, ModuleDescription> modules = data.modules;
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1584
        List<PlatformInput> versions = data.versions;
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1585
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1586
        ExcludeIncludeList excludeList =
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1587
                ExcludeIncludeList.create(excludeFile);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1588
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1589
        Iterable<byte[]> classBytes = dumpCurrentClasses();
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1590
        loadVersionClasses(classes, modules, classBytes, excludeList, currentVersion);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1591
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1592
        String baseline;
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1593
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1594
        if (versions.isEmpty()) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1595
            baseline = null;
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1596
        } else {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1597
            baseline = versions.stream()
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1598
                               .sorted((v1, v2) -> v2.version.compareTo(v1.version))
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1599
                               .findFirst()
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1600
                               .get()
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1601
                               .version;
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1602
        }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1603
51799
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1604
        versions.add(new PlatformInput(null, currentVersion, baseline, null));
50027
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1605
        dumpDescriptions(classes, modules, versions, ctDescriptionPath, args);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1606
    }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1607
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1608
    private List<byte[]> dumpCurrentClasses() throws IOException {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1609
        JavacTool tool = JavacTool.create();
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1610
        Context ctx = new Context();
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1611
        String version = System.getProperty("java.specification.version");
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1612
        JavacTask task = tool.getTask(null, null, null,
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1613
                                      List.of("--release", version),
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1614
                                      null, null, ctx);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1615
        task.getElements().getTypeElement("java.lang.Object");
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1616
        JavaFileManager fm = ctx.get(JavaFileManager.class);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1617
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1618
        List<byte[]> data = new ArrayList<>();
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1619
        for (Location modLoc : LOCATIONS) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1620
            for (Set<JavaFileManager.Location> module :
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1621
                    fm.listLocationsForModules(modLoc)) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1622
                for (JavaFileManager.Location loc : module) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1623
                    Iterable<JavaFileObject> files =
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1624
                            fm.list(loc,
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1625
                                    "",
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1626
                                    EnumSet.of(Kind.CLASS),
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1627
                                    true);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1628
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1629
                    for (JavaFileObject jfo : files) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1630
                        try (InputStream is = jfo.openInputStream();
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1631
                             InputStream in =
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1632
                                     new BufferedInputStream(is)) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1633
                            ByteArrayOutputStream baos =
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1634
                                    new ByteArrayOutputStream();
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1635
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1636
                            in.transferTo(baos);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1637
                            data.add(baos.toByteArray());
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1638
                        }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1639
                    }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1640
                }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1641
            }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1642
        }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1643
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1644
        return data;
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1645
    }
47703
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1646
    //where:
50027
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1647
        private static final List<StandardLocation> LOCATIONS =
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  1648
                List.of(StandardLocation.SYSTEM_MODULES,
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1659
        if (cf.access_flags.is(AccessFlags.ACC_MODULE)) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1660
            return ;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1661
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1727
    private void inspectModuleInfoClassFile(InputStream in,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1728
            Map<String, ModuleDescription> modules,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1729
            String version) throws IOException, ConstantPoolException {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1730
        ClassFile cf = ClassFile.read(in);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1731
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1732
        if (!cf.access_flags.is(AccessFlags.ACC_MODULE)) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1733
            return ;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1734
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1735
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1736
        ModuleHeaderDescription headerDesc = new ModuleHeaderDescription();
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1737
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1738
        headerDesc.versions = version;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1739
        headerDesc.flags = cf.access_flags.flags;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1740
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1741
        for (Attribute attr : cf.attributes) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1742
            if (!readAttribute(cf, headerDesc, attr))
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1743
                return ;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1744
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1745
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1746
        String name = headerDesc.name;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1747
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1748
        ModuleDescription moduleDesc = modules.get(name);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1749
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1750
        if (moduleDesc == null) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1751
            moduleDesc = new ModuleDescription();
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1752
            moduleDesc.name = name;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1753
            modules.put(moduleDesc.name, moduleDesc);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1754
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1755
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1756
        addModuleHeader(moduleDesc, headerDesc, version);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1757
    }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1758
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1759
    private void addModuleHeader(ModuleDescription moduleDesc,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1760
                                 ModuleHeaderDescription headerDesc,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1761
                                 String version) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1762
        //normalize:
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1763
        boolean existed = false;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1764
        for (ModuleHeaderDescription existing : moduleDesc.header) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1765
            if (existing.equals(headerDesc)) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1766
                headerDesc = existing;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1767
                existed = true;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1768
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1769
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1770
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1771
        headerDesc.versions += version;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1772
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1773
        if (!existed) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1774
            moduleDesc.header.add(headerDesc);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1775
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1776
    }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1797
                            existing.classAnnotations = new ArrayList<>(annots);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1871
                if (feature instanceof ModuleHeaderDescription)
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1930
            case Attribute.Module: {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1931
                assert feature instanceof ModuleHeaderDescription;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1932
                ModuleHeaderDescription header =
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1933
                        (ModuleHeaderDescription) feature;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1934
                Module_attribute mod = (Module_attribute) attr;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1935
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1936
                header.name = cf.constant_pool
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1937
                                .getModuleInfo(mod.module_name)
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1938
                                .getName();
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1939
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1940
                header.exports =
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1941
                        Arrays.stream(mod.exports)
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1942
                              .filter(ee -> ee.exports_to_count == 0)
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1943
                              .map(ee -> getPackageName(cf, ee.exports_index))
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1944
                              .collect(Collectors.toList());
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1945
                header.requires =
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1946
                        Arrays.stream(mod.requires)
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1947
                              .map(r -> RequiresDescription.create(cf, r))
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1948
                              .collect(Collectors.toList());
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1949
                header.uses = Arrays.stream(mod.uses_index)
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1950
                                    .mapToObj(use -> getClassName(cf, use))
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1951
                                    .collect(Collectors.toList());
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1952
                header.provides =
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1953
                        Arrays.stream(mod.provides)
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1954
                              .map(p -> ProvidesDescription.create(cf, p))
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1955
                              .collect(Collectors.toList());
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1956
                break;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1957
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1958
            case Attribute.ModuleTarget: {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1959
                assert feature instanceof ModuleHeaderDescription;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1960
                ModuleHeaderDescription header =
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1961
                        (ModuleHeaderDescription) feature;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1962
                ModuleTarget_attribute mod = (ModuleTarget_attribute) attr;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1963
                if (mod.target_platform_index != 0) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1964
                    header.moduleTarget =
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1965
                            cf.constant_pool
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1966
                              .getUTF8Value(mod.target_platform_index);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1967
                }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1968
                break;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1969
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1970
            case Attribute.ModuleResolution: {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1971
                assert feature instanceof ModuleHeaderDescription;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1972
                ModuleHeaderDescription header =
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1973
                        (ModuleHeaderDescription) feature;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1974
                ModuleResolution_attribute mod =
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1975
                        (ModuleResolution_attribute) attr;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1976
                header.moduleResolution = mod.resolution_flags;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1977
                break;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1978
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1979
            case Attribute.ModulePackages:
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1980
            case Attribute.ModuleHashes:
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1981
                break;
51799
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1982
            case Attribute.NestHost: {
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1983
                assert feature instanceof ClassHeaderDescription;
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1984
                NestHost_attribute nestHost = (NestHost_attribute) attr;
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1985
                ClassHeaderDescription chd = (ClassHeaderDescription) feature;
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1986
                chd.nestHost = nestHost.getNestTop(cf.constant_pool).getName();
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1987
                break;
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1988
            }
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1989
            case Attribute.NestMembers: {
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1990
                assert feature instanceof ClassHeaderDescription;
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1991
                NestMembers_attribute nestMembers = (NestMembers_attribute) attr;
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1992
                ClassHeaderDescription chd = (ClassHeaderDescription) feature;
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1993
                chd.nestMembers = Arrays.stream(nestMembers.members_indexes)
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1994
                                        .mapToObj(i -> getClassName(cf, i))
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1995
                                        .collect(Collectors.toList());
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1996
                break;
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  1997
            }
31506
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff changeset
  1998
            default:
47703
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  1999
                throw new IllegalStateException("Unhandled attribute: " +
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2006
    private static String getClassName(ClassFile cf, int idx) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2007
        try {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2008
            return cf.constant_pool.getClassInfo(idx).getName();
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2009
        } catch (InvalidIndex ex) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2010
            throw new IllegalStateException(ex);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2011
        } catch (ConstantPool.UnexpectedEntry ex) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2012
            throw new IllegalStateException(ex);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2013
        } catch (ConstantPoolException ex) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2014
            throw new IllegalStateException(ex);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2015
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2016
    }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2017
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2018
    private static String getPackageName(ClassFile cf, int idx) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2019
        try {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2020
            return cf.constant_pool.getPackageInfo(idx).getName();
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2021
        } catch (InvalidIndex ex) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2022
            throw new IllegalStateException(ex);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2023
        } catch (ConstantPool.UnexpectedEntry ex) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2024
            throw new IllegalStateException(ex);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2025
        } catch (ConstantPoolException ex) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2026
            throw new IllegalStateException(ex);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2027
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2028
    }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2029
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2030
    private static String getModuleName(ClassFile cf, int idx) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2031
        try {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2032
            return cf.constant_pool.getModuleInfo(idx).getName();
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2033
        } catch (InvalidIndex ex) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2034
            throw new IllegalStateException(ex);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2035
        } catch (ConstantPool.UnexpectedEntry ex) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2036
            throw new IllegalStateException(ex);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2037
        } catch (ConstantPoolException ex) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2038
            throw new IllegalStateException(ex);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2039
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2040
    }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2041
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2042
    private static Integer getVersion(ClassFile cf, int idx) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2043
        if (idx == 0)
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2044
            return null;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2045
        try {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2046
            return ((CONSTANT_Integer_info) cf.constant_pool.get(idx)).value;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2047
        } catch (InvalidIndex ex) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2048
            throw new IllegalStateException(ex);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2049
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2050
    }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2241
    static boolean checkChange(String versions, String version,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2242
                               String baselineVersion) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2243
        return versions.contains(version) ^
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2244
               (baselineVersion != null &&
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2245
                versions.contains(baselineVersion));
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2246
    }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2350
    public static class ModuleDescription {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2351
        String name;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2352
        List<ModuleHeaderDescription> header = new ArrayList<>();
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2353
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2354
        public void write(Appendable output, String baselineVersion,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2355
                          String version) throws IOException {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2356
            boolean inBaseline = false;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2357
            boolean inVersion = false;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2358
            for (ModuleHeaderDescription mhd : header) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2359
                if (baselineVersion != null &&
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2360
                    mhd.versions.contains(baselineVersion)) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2361
                    inBaseline = true;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2362
                }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2363
                if (mhd.versions.contains(version)) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2364
                    inVersion = true;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2365
                }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2366
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2367
            if (!inVersion && !inBaseline)
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2368
                return ;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2369
            if (!inVersion) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2370
                output.append("-module name " + name + "\n\n");
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2371
                return;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2372
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2373
            boolean hasChange = hasChange(header, version, baselineVersion);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2374
            if (!hasChange)
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2375
                return;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2376
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2377
            output.append("module name " + name + "\n");
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2378
            for (ModuleHeaderDescription header : header) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2379
                header.write(output, baselineVersion, version);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2380
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2381
            output.append("\n");
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2382
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2383
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2384
        boolean hasChange(List<? extends FeatureDescription> hasChange,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2385
                          String version, String baseline) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2386
            return hasChange.stream()
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2387
                            .map(fd -> fd.versions)
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2388
                            .anyMatch(versions -> checkChange(versions,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2389
                                                              version,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2390
                                                              baseline));
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2391
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2392
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2393
        public void read(LineBasedReader reader, String baselineVersion,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2394
                         String version) throws IOException {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2395
            if (!"module".equals(reader.lineKey))
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2396
                return ;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2397
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2398
            name = reader.attributes.get("name");
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2399
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2400
            reader.moveNext();
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2401
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2402
            OUTER: while (reader.hasNext()) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2403
                switch (reader.lineKey) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2404
                    case "header":
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2405
                        removeVersion(header, h -> true, version);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2406
                        ModuleHeaderDescription mhd =
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2407
                                new ModuleHeaderDescription();
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2408
                        mhd.read(reader);
50027
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  2409
                        mhd.name = name;
47703
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2410
                        mhd.versions = version;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2411
                        header.add(mhd);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2412
                        break;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2413
                    case "class":
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2414
                    case "-class":
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2415
                    case "module":
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2416
                    case "-module":
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2417
                        break OUTER;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2418
                    default:
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2419
                        throw new IllegalStateException(reader.lineKey);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2420
                }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2421
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2422
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2423
    }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2424
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2425
    static class ModuleHeaderDescription extends HeaderDescription {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2426
        String name;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2427
        List<String> exports = new ArrayList<>();
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2428
        List<String> opens = new ArrayList<>();
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2429
        List<RequiresDescription> requires = new ArrayList<>();
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2430
        List<String> uses = new ArrayList<>();
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2431
        List<ProvidesDescription> provides = new ArrayList<>();
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2432
        Integer moduleResolution;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2433
        String moduleTarget;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2434
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2435
        @Override
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2436
        public int hashCode() {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2437
            int hash = super.hashCode();
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2438
            hash = 83 * hash + Objects.hashCode(this.name);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2439
            hash = 83 * hash + Objects.hashCode(this.exports);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2440
            hash = 83 * hash + Objects.hashCode(this.opens);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2441
            hash = 83 * hash + Objects.hashCode(this.requires);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2442
            hash = 83 * hash + Objects.hashCode(this.uses);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2443
            hash = 83 * hash + Objects.hashCode(this.provides);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2444
            hash = 83 * hash + Objects.hashCode(this.moduleResolution);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2445
            hash = 83 * hash + Objects.hashCode(this.moduleTarget);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2446
            return hash;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2447
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2448
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2449
        @Override
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2450
        public boolean equals(Object obj) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2451
            if (this == obj) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2452
                return true;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2453
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2454
            if (!super.equals(obj)) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2455
                return false;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2456
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2457
            final ModuleHeaderDescription other =
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2458
                    (ModuleHeaderDescription) obj;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2459
            if (!Objects.equals(this.name, other.name)) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2460
                return false;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2461
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2462
            if (!listEquals(this.exports, other.exports)) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2463
                return false;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2464
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2465
            if (!listEquals(this.opens, other.opens)) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2466
                return false;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2467
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2468
            if (!listEquals(this.requires, other.requires)) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2469
                return false;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2470
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2471
            if (!listEquals(this.uses, other.uses)) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2472
                return false;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2473
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2474
            if (!listEquals(this.provides, other.provides)) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2475
                return false;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2476
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2477
            if (!Objects.equals(this.moduleTarget, other.moduleTarget)) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2478
                return false;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2479
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2480
            if (!Objects.equals(this.moduleResolution,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2481
                                other.moduleResolution)) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2482
                return false;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2483
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2484
            return true;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2485
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2486
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2487
        @Override
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2488
        public void write(Appendable output, String baselineVersion,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2489
                          String version) throws IOException {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2490
            if (!versions.contains(version) ||
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2491
                (baselineVersion != null && versions.contains(baselineVersion)
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2492
                 && versions.contains(version)))
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2493
                return ;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2494
            output.append("header");
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2495
            if (exports != null && !exports.isEmpty())
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2496
                output.append(" exports " + serializeList(exports));
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2497
            if (opens != null && !opens.isEmpty())
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2498
                output.append(" opens " + serializeList(opens));
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2499
            if (requires != null && !requires.isEmpty()) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2500
                List<String> requiresList =
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2501
                        requires.stream()
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2502
                                .map(req -> req.serialize())
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2503
                                .collect(Collectors.toList());
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2504
                output.append(" requires " + serializeList(requiresList));
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2505
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2506
            if (uses != null && !uses.isEmpty())
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2507
                output.append(" uses " + serializeList(uses));
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2508
            if (provides != null && !provides.isEmpty()) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2509
                List<String> providesList =
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2510
                        provides.stream()
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2511
                                .map(p -> p.serialize())
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2512
                                .collect(Collectors.toList());
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2513
                output.append(" provides " + serializeList(providesList));
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2514
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2515
            if (moduleTarget != null)
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2516
                output.append(" target " + quote(moduleTarget, true));
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2517
            if (moduleResolution != null)
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2518
                output.append(" resolution " +
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2519
                              quote(Integer.toHexString(moduleResolution),
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2520
                                    true));
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2521
            writeAttributes(output);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2522
            output.append("\n");
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2523
            writeInnerClasses(output, baselineVersion, version);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2524
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2525
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2526
        private static Map<String, String> splitAttributes(String data) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2527
            String[] parts = data.split(" ");
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2528
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2529
            Map<String, String> attributes = new HashMap<>();
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2530
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2531
            for (int i = 0; i < parts.length; i += 2) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2532
                attributes.put(parts[i], unquote(parts[i + 1]));
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2533
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2534
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2535
            return attributes;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2536
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2537
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2538
        @Override
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2539
        public boolean read(LineBasedReader reader) throws IOException {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2540
            if (!"header".equals(reader.lineKey))
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2541
                return false;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2542
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2543
            exports = deserializeList(reader.attributes.get("exports"));
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2544
            opens = deserializeList(reader.attributes.get("opens"));
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2545
            List<String> requiresList =
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2546
                    deserializeList(reader.attributes.get("requires"));
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2547
            requires = requiresList.stream()
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2548
                                   .map(RequiresDescription::deserialize)
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2549
                                   .collect(Collectors.toList());
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2550
            uses = deserializeList(reader.attributes.get("uses"));
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2551
            List<String> providesList =
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2552
                    deserializeList(reader.attributes.get("provides"), false);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2553
            provides = providesList.stream()
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2554
                                   .map(ProvidesDescription::deserialize)
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2555
                                   .collect(Collectors.toList());
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2556
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2557
            moduleTarget = reader.attributes.get("target");
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2558
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2559
            if (reader.attributes.containsKey("resolution")) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2560
                final String resolutionFlags =
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2561
                        reader.attributes.get("resolution");
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2562
                moduleResolution = Integer.parseInt(resolutionFlags, 16);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2563
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2564
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2565
            readAttributes(reader);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2566
            reader.moveNext();
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2567
            readInnerClasses(reader);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2568
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2569
            return true;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2570
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2571
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2572
        static class RequiresDescription {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2573
            final String moduleName;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2574
            final int flags;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2575
            final Integer version;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2576
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2577
            public RequiresDescription(String moduleName, int flags,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2578
                                       Integer version) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2579
                this.moduleName = moduleName;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2580
                this.flags = flags;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2581
                this.version = version;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2582
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2583
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2584
            public String serialize() {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2585
                String versionKeyValue = version != null
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2586
                        ? " version " + quote(String.valueOf(version), true)
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2587
                        : "";
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2588
                return "name " + quote(moduleName, true) +
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2589
                       " flags " + quote(Integer.toHexString(flags), true) +
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2590
                       versionKeyValue;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2591
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2592
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2593
            public static RequiresDescription deserialize(String data) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2594
                Map<String, String> attributes = splitAttributes(data);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2595
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2596
                Integer ver = attributes.containsKey("version")
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2597
                        ? Integer.parseInt(attributes.get("version"))
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2598
                        : null;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2599
                int flags = Integer.parseInt(attributes.get("flags"), 16);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2600
                return new RequiresDescription(attributes.get("name"),
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2601
                                               flags,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2602
                                               ver);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2603
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2604
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2605
            public static RequiresDescription create(ClassFile cf,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2606
                                                     RequiresEntry req) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2607
                String mod = getModuleName(cf, req.requires_index);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2608
                Integer ver = getVersion(cf, req.requires_version_index);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2609
                return new RequiresDescription(mod,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2610
                                               req.requires_flags,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2611
                                               ver);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2612
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2613
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2614
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2615
        static class ProvidesDescription {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2616
            final String interfaceName;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2617
            final List<String> implNames;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2618
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2619
            public ProvidesDescription(String interfaceName,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2620
                                       List<String> implNames) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2621
                this.interfaceName = interfaceName;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2622
                this.implNames = implNames;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2623
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2624
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2625
            public String serialize() {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2626
                return "interface " + quote(interfaceName, true) +
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2627
                       " impls " + quote(serializeList(implNames), true, true);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2628
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2629
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2630
            public static ProvidesDescription deserialize(String data) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2631
                Map<String, String> attributes = splitAttributes(data);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2632
                List<String> implsList =
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2633
                        deserializeList(attributes.get("impls"),
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2634
                                        false);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2635
                return new ProvidesDescription(attributes.get("interface"),
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2636
                                               implsList);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2637
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2638
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2639
            public static ProvidesDescription create(ClassFile cf,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2640
                                                     ProvidesEntry prov) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2641
                String api = getClassName(cf, prov.provides_index);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2642
                List<String> impls =
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2643
                        Arrays.stream(prov.with_index)
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2644
                              .mapToObj(wi -> getClassName(cf, wi))
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2645
                              .collect(Collectors.toList());
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2646
                return new ProvidesDescription(api, impls);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2647
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2648
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2649
    }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2657
        public void write(Appendable output, String baselineVersion,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2662
                if (baselineVersion != null &&
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2695
        boolean hasChange(List<? extends FeatureDescription> hasChange,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2696
                          String version,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2700
                            .anyMatch(versions -> checkChange(versions,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2701
                                                              version,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2705
        public void read(LineBasedReader reader, String baselineVersion,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2753
                    case "module":
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2761
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2762
        public String packge() {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2763
            String pack;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2764
            int lastSlash = name.lastIndexOf('/');
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2765
            if (lastSlash != (-1)) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2766
                pack = name.substring(0, lastSlash).replace('/', '.');
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2767
            } else {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2768
                pack = "";
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2769
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2770
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2771
            return pack;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  2778
        String nestHost;
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  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
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  2786
            hash = 17 * hash + Objects.hashCode(this.nestHost);
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  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
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  2806
            if (!Objects.equals(this.nestHost, other.nestHost)) {
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  2807
                return false;
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  2808
            }
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  2809
            if (!Objects.equals(this.nestMembers, other.nestMembers)) {
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  2810
                return false;
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  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
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  2825
            if (nestHost != null)
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  2826
                output.append(" nestHost " + nestHost);
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  2827
            if (nestMembers != null && !nestMembers.isEmpty())
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2831
            writeInnerClasses(output, baselineVersion, version);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2832
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2833
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2834
        @Override
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2835
        public boolean read(LineBasedReader reader) throws IOException {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2836
            if (!"header".equals(reader.lineKey))
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2837
                return false;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2838
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2839
            extendsAttr = reader.attributes.get("extends");
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2840
            String elementsList = reader.attributes.get("implements");
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2841
            implementsAttr = deserializeList(elementsList);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2842
51799
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  2843
            nestHost = reader.attributes.get("nestHost");
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  2844
            String nestMembersList = reader.attributes.get("nestMembers");
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  2845
            nestMembers = deserializeList(nestMembersList);
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  2846
47703
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2847
            readAttributes(reader);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2848
            reader.moveNext();
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2849
            readInnerClasses(reader);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2850
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2851
            return true;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2852
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2853
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2854
    }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2855
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2856
    static abstract class HeaderDescription extends FeatureDescription {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2857
        List<InnerClassInfo> innerClasses;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2858
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2859
        @Override
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2860
        public int hashCode() {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2861
            int hash = super.hashCode();
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2862
            hash = 19 * hash + Objects.hashCode(this.innerClasses);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2863
            return hash;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2864
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2865
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2866
        @Override
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2867
        public boolean equals(Object obj) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2868
            if (obj == null) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2869
                return false;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2870
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2871
            if (!super.equals(obj)) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2872
                return false;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2873
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2874
            final HeaderDescription other = (HeaderDescription) obj;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2875
            if (!listEquals(this.innerClasses, other.innerClasses)) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2876
                return false;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2877
            }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2878
            return true;
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2879
        }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2880
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2881
        protected void writeInnerClasses(Appendable output,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  2882
                                         String baselineVersion,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  3008
            String thrownTypesValue = reader.attributes.get("thrownTypes");
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  3009
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  3010
            if (thrownTypesValue != null) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  3011
                thrownTypes = deserializeList(thrownTypesValue);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  3450
        return deserializeList(serialized, true);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  3451
    }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  3452
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  3453
    private static List<String> deserializeList(String serialized,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  3454
                                                boolean unquote) {
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  3462
        return quote(value, quoteQuotes, false);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  3463
    }
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  3464
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  3465
    private static String quote(String value, boolean quoteQuotes,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  3470
            if (c <= 32 || c >= 127 || c == '\\' ||
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  3608
            case "build-description": {
47703
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  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
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  3641
                ExcludeIncludeList excludeList =
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  3642
                        ExcludeIncludeList.create(args[2]);
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  3643
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  3644
                new CreateSymbols().createBaseLine(versions,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  3645
                                                   excludeList,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  3646
                                                   descDest,
dbfac941197a 8180744: Update ct.sym for JDK 10
jlahoda
parents: 47216
diff changeset
  3647
                                                   args);
31506
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff changeset
  3648
                break;
50027
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  3649
            }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  3650
            case "build-description-incremental": {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  3651
                if (args.length != 3) {
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  3652
                    help();
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  3653
                    return ;
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  3654
                }
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  3655
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  3656
                new CreateSymbols().createIncrementalBaseLine(args[1], args[2], args);
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  3657
                break;
69aadf0c1e69 8202387: javac --release 11 not supported
jlahoda
parents: 47703
diff changeset
  3658
            }
31506
4e07f827a794 8072480: javac should support compilation for a specific platform version
jlahoda
parents:
diff changeset
  3659
            case "build-ctsym":
51799
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  3660
                String ctDescriptionFileExtra;
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  3661
                String ctDescriptionFile;
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  3662
                String ctSymLocation;
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  3663
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  3664
                if (args.length == 3) {
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  3665
                    ctDescriptionFileExtra = null;
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  3666
                    ctDescriptionFile = args[1];
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  3667
                    ctSymLocation = args[2];
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  3668
                } else if (args.length == 4) {
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  3669
                    ctDescriptionFileExtra = args[1];
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  3670
                    ctDescriptionFile = args[2];
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  3671
                    ctSymLocation = args[3];
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  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
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  3677
                new CreateSymbols().createSymbols(ctDescriptionFileExtra,
3fabe59fe4de 8207954: Data for --release 11
jlahoda
parents: 50027
diff changeset
  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
}