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