< prev index next > src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java
Print this page
import com.sun.tools.javac.file.BaseFileManager;
import com.sun.tools.javac.file.PathFileObject;
import com.sun.tools.javac.jvm.ClassFile.Version;
import com.sun.tools.javac.jvm.PoolConstant.NameAndType;
import com.sun.tools.javac.main.Option;
+ import com.sun.tools.javac.resources.CompilerProperties;
import com.sun.tools.javac.resources.CompilerProperties.Fragments;
import com.sun.tools.javac.resources.CompilerProperties.Warnings;
+ import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.util.*;
import com.sun.tools.javac.util.ByteBuffer.UnderflowException;
import com.sun.tools.javac.util.DefinedBy.Api;
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
import com.sun.tools.javac.util.JCDiagnostic.Fragment;
import static com.sun.tools.javac.code.Flags.*;
import static com.sun.tools.javac.code.Kinds.Kind.*;
import com.sun.tools.javac.code.Scope.LookupKind;
+ import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE;
import static com.sun.tools.javac.code.TypeTag.ARRAY;
import static com.sun.tools.javac.code.TypeTag.CLASS;
import static com.sun.tools.javac.code.TypeTag.TYPEVAR;
import static com.sun.tools.javac.jvm.ClassFile.*;
import static com.sun.tools.javac.jvm.ClassFile.Version.*;
/** Switch: allow modules.
*/
boolean allowModules;
+ /** Switch: allow value classes.
+ */
+ boolean allowValueClasses;
+
/** Switch: allow sealed
*/
boolean allowSealedTypes;
/** Switch: allow records
verbose = options.isSet(Option.VERBOSE);
Source source = Source.instance(context);
preview = Preview.instance(context);
allowModules = Feature.MODULES.allowedInSource(source);
+ allowValueClasses = (!preview.isPreview(Feature.VALUE_CLASSES) || preview.isEnabled()) &&
+ Feature.VALUE_CLASSES.allowedInSource(source);
allowRecords = Feature.RECORDS.allowedInSource(source);
allowSealedTypes = Feature.SEALED_CLASSES.allowedInSource(source);
warnOnIllegalUtf8 = Feature.WARN_ON_ILLEGAL_UTF8.allowedInSource(source);
saveParameterNames = options.isSet(PARAMETERS);
Type classSigToType() {
if (signature[sigp] != 'L')
throw badClassFile("bad.class.signature", quoteBadSignature());
sigp++;
Type outer = Type.noType;
+ Name name;
int startSbp = sbp;
while (true) {
final byte c = signature[sigp++];
switch (c) {
ClassSymbol t = enterClass(readName(signatureBuffer,
startSbp,
sbp - startSbp));
try {
- return (outer == Type.noType) ?
- t.erasure(types) :
- new ClassType(outer, List.nil(), t);
+ if (outer == Type.noType) {
+ ClassType et = (ClassType) t.erasure(types);
+ return new ClassType(et.getEnclosingType(), List.nil(), et.tsym, et.getMetadata());
+ }
+ return new ClassType(outer, List.nil(), t, List.nil());
} finally {
sbp = startSbp;
}
}
case '<': // generic arguments
ClassSymbol t = enterClass(readName(signatureBuffer,
startSbp,
sbp - startSbp));
- outer = new ClassType(outer, sigToTypes('>'), t) {
+ outer = new ClassType(outer, sigToTypes('>'), t, List.nil()) {
boolean completed = false;
@Override @DefinedBy(Api.LANGUAGE_MODEL)
public Type getEnclosingType() {
if (!completed) {
completed = true;
//we have seen an enclosing non-generic class
if (outer != Type.noType) {
t = enterClass(readName(signatureBuffer,
startSbp,
sbp - startSbp));
- outer = new ClassType(outer, List.nil(), t);
+ outer = new ClassType(outer, List.nil(), t, List.nil());
}
signatureBuffer[sbp++] = (byte)'$';
continue;
case '/':
signatureBuffer[sbp++] = (byte)'.';
/************************************************************************
* Adjusting flags
***********************************************************************/
long adjustFieldFlags(long flags) {
+ boolean previewClassFile = minorVersion == ClassFile.PREVIEW_MINOR_VERSION;
+ if (allowValueClasses && previewClassFile && (flags & ACC_STRICT) != 0) {
+ flags &= ~ACC_STRICT;
+ flags |= STRICT;
+ }
return flags;
}
long adjustMethodFlags(long flags) {
if ((flags & ACC_BRIDGE) != 0) {
}
return flags;
}
long adjustClassFlags(long flags) {
+ boolean previewClassFile = minorVersion == ClassFile.PREVIEW_MINOR_VERSION;
if ((flags & ACC_MODULE) != 0) {
flags &= ~ACC_MODULE;
flags |= MODULE;
}
- return flags & ~ACC_SUPER; // SUPER and SYNCHRONIZED bits overloaded
+ if ((flags & ACC_IDENTITY) != 0 || (majorVersion < V66.major && (flags & INTERFACE) == 0)) {
+ flags |= IDENTITY_TYPE;
+ } else if ((flags & INTERFACE) == 0 && allowValueClasses && previewClassFile && majorVersion >= V66.major) {
+ flags |= VALUE_CLASS;
+ }
+ flags &= ~ACC_IDENTITY; // ACC_IDENTITY and SYNCHRONIZED bits overloaded
+ return flags;
}
/**
* A subclass of JavaFileObject for the sourcefile attribute found in a classfile.
* The attribute is only the last component of the original filename, so is unlikely
< prev index next >