diff options
Diffstat (limited to 'org.eclipse.jdt.core/model/org/eclipse/jdt/core')
7 files changed, 175 insertions, 4 deletions
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Flags.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Flags.java index 4950c1bfd1..8fe20ea15b 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Flags.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Flags.java @@ -193,6 +193,26 @@ public final class Flags { * @noreference This field is not intended to be referenced by clients as it is a part of Java preview feature. */ public static final int AccRecord = ExtraCompilerModifiers.AccRecord; + /** + * Sealed property flag. + * <p> + * Note that this flag's value is internal and is not defined in the + * Virtual Machine specification. + * </p> + * @since 3.23 + * @noreference This field is not intended to be referenced by clients as it is a part of Java preview feature. + */ + public static final int AccSealed = ExtraCompilerModifiers.AccSealed; + /** + * Non-sealed property flag. + * <p> + * Note that this flag's value is internal and is not defined in the + * Virtual Machine specification. + * </p> + * @since 3.23 + * @noreference This field is not intended to be referenced by clients as it is a part of Java preview feature. + */ + public static final int AccNonSealed = ExtraCompilerModifiers.AccNonSealed; /** * Not instantiable. @@ -402,6 +422,30 @@ public final class Flags { public static boolean isRecord(int flags) { return (flags & AccRecord) != 0; } + /** + * Returns whether the given integer has the <code>AccSealed</code> + * bit set. + * + * @param flags the flags + * @return <code>true</code> if the <code>AccSealed</code> flag is included + * @see #AccSealed + * @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature. + */ + public static boolean isSealed(int flags) { + return (flags & AccSealed) != 0; + } + /** + * Returns whether the given integer has the <code>AccNonSealed</code> + * bit set. + * + * @param flags the flags + * @return <code>true</code> if the <code>AccNonSealed</code> flag is included + * @see #AccNonSealed + * @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature. + */ + public static boolean isNonSealed(int flags) { + return (flags & AccNonSealed) != 0; + } /** * Returns whether the given integer has the <code>AccAnnotation</code> diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IType.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IType.java index 0d16aaf890..3550361b88 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IType.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IType.java @@ -759,6 +759,22 @@ public interface IType extends IMember, IAnnotatable { String[] getSuperInterfaceNames() throws JavaModelException; /** + * Returns the names of types that this sealed type permits to be its sub types. + * For a non sealed type, an empty array is returned. + * If type declares an explicit permits clause, then the permitted sub-types + * are returned in the declared order. If a sealed type does not explicitly + * declare permitted sub types, then the implicit permitted types, that is, + * the types in the same compilation unit that are sub types of this sealed type + * are returned in the order they appear within the compilation unit. + * + * @exception JavaModelException if this element does not exist or if an + * exception occurs while accessing its corresponding resource. + * @return names of types that this type permits to be its sub types + * @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature. + */ + String[] getPermittedSubtypeNames() throws JavaModelException; + + /** * Returns the formal type parameter signatures for this type. * Returns an empty array if this type has no formal type parameters. * <p> @@ -915,6 +931,16 @@ public interface IType extends IMember, IAnnotatable { */ boolean isRecord() throws JavaModelException; /** + * Returns whether this type is a sealed type. + * + * @exception JavaModelException if this element does not exist or if an + * exception occurs while accessing its corresponding resource. + * @return true if this type this type is a sealed type, false otherwise + * @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature. + */ + boolean isSealed() throws JavaModelException; + + /** * Returns the record components declared by this record class, or an empty * array if this is not a record. * @@ -924,7 +950,7 @@ public interface IType extends IMember, IAnnotatable { * @noreference This method is not intended to be referenced by clients as it is a part of Java preview feature. */ default IField[] getRecordComponents() throws JavaModelException { - return null; + return new IField[0]; } /** * Returns the record component with the specified name diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java index b2a9d2b068..733c9b90a5 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java @@ -3120,12 +3120,18 @@ public final class JavaCore extends Plugin { public static final String VERSION_14 = "14"; //$NON-NLS-1$ /** * Configurable option value: {@value}. + * @since 3.23 + * @category OptionValue + */ + public static final String VERSION_15 = "15"; //$NON-NLS-1$ + /** + * Configurable option value: {@value}. * @since 3.4 * @category OptionValue */ public static final String VERSION_CLDC_1_1 = "cldc1.1"; //$NON-NLS-1$ private static List<String> allVersions = Collections.unmodifiableList(Arrays.asList(VERSION_CLDC_1_1, VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4, VERSION_1_5, - VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9, VERSION_10, VERSION_11, VERSION_12, VERSION_13, VERSION_14)); + VERSION_1_6, VERSION_1_7, VERSION_1_8, VERSION_9, VERSION_10, VERSION_11, VERSION_12, VERSION_13, VERSION_14, VERSION_15)); /** * Returns all {@link JavaCore}{@code #VERSION_*} levels in the order of their diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IAttributeNamesConstants.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IAttributeNamesConstants.java index c3f2ddabab..297f1f5364 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IAttributeNamesConstants.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IAttributeNamesConstants.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2018 IBM Corporation and others. + * Copyright (c) 2000, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -207,6 +207,11 @@ public interface IAttributeNamesConstants { * @since 3.22 */ char[] RECORD = "Record".toCharArray(); //$NON-NLS-1$ + /** + * "PermittedSubclasses" attribute (JVMS 15). + * @since 3.23 + */ + char[] PERMITTED_SUBCLASSES = "PermittedSubclasses".toCharArray(); //$NON-NLS-1$ } diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IClassFileReader.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IClassFileReader.java index f72dafb9ea..22b21f38b6 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IClassFileReader.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IClassFileReader.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2018 IBM Corporation and others. + * Copyright (c) 2000, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -137,6 +137,16 @@ public interface IClassFileReader { } /** + * Answer back the permitted subclasses attribute of this .class file, null if none. + * + * @return the permitted subclasses attribute of this .class file, null if none + * @since 3.23 + */ + default IPermittedSubclassesAttribute getPermittedSubclassesAttribute() { + return null; + } + + /** * Answer back the array of method infos of this .class file, * an empty array if none. * diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IPermittedSubclassesAttribute.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IPermittedSubclassesAttribute.java new file mode 100644 index 0000000000..467bb00f69 --- /dev/null +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IPermittedSubclassesAttribute.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2000, 2020 IBM Corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.jdt.core.util; + +/** + * Description of permitted subclasses attribute as described in the JVM + * specifications. + * + * @since 3.23 + */ +public interface IPermittedSubclassesAttribute extends IClassFileAttribute { + + /** + * Answer back the number of permitted subclasses as specified in + * the JVM specifications. + * + * @return the number of permitted subclasses as specified in + * the JVM specifications + */ + int getNumberOfPermittedSubclasses(); + + /** + * Answer back the array of permitted subclass attribute entries as specified in + * the JVM specifications, or an empty array if none. + * + * @return the array of permitted subclass attribute entries as specified in + * the JVM specifications, or an empty array if none + */ + IPermittedSubclassesAttributeEntry[] getPermittedSubclassAttributesEntries(); +} diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IPermittedSubclassesAttributeEntry.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IPermittedSubclassesAttributeEntry.java new file mode 100644 index 0000000000..3c3dc95677 --- /dev/null +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IPermittedSubclassesAttributeEntry.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2000, 2020 IBM Corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.jdt.core.util; + +/** + * Description of permitted subclasses attribute as described in the JVM + * specifications. + * + * @since 3.23 + */ +public interface IPermittedSubclassesAttributeEntry { + + /** + * Answer back the permitted subclass name as specified + * in the JVM specifications. + * + * @return the permitted subclass name as specified + * in the JVM specifications + */ + char[] getPermittedSubclassName(); + + /** + * Answer back the permitted subclass name index. + * + * @return the permitted class name index + */ + int gePermittedSubclassIndex(); +} |