< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java

Print this page
@@ -39,10 +39,11 @@
  import com.sun.tools.javac.code.Scope.NamedImportScope;
  import com.sun.tools.javac.code.Scope.StarImportScope;
  import com.sun.tools.javac.code.Scope.WriteableScope;
  import com.sun.tools.javac.code.Source.Feature;
  import com.sun.tools.javac.comp.Annotate.AnnotationTypeMetadata;
+ import com.sun.tools.javac.jvm.Target;
  import com.sun.tools.javac.tree.*;
  import com.sun.tools.javac.util.*;
  import com.sun.tools.javac.util.DefinedBy.Api;
  
  import com.sun.tools.javac.code.Symbol.*;

@@ -688,10 +689,11 @@
              ClassSymbol sym = tree.sym;
              ClassType ct = (ClassType)sym.type;
              // Determine supertype.
              Type supertype;
              JCExpression extending;
+             final boolean isPrimitiveClass = (tree.mods.flags & Flags.PRIMITIVE_CLASS) != 0;
  
              if (tree.extending != null) {
                  extending = clearTypeParams(tree.extending);
                  supertype = attr.attribBase(extending, baseEnv, true, false, true);
                  if (supertype == syms.recordType) {

@@ -717,10 +719,13 @@
              List<JCExpression> interfaceTrees = tree.implementing;
              for (JCExpression iface : interfaceTrees) {
                  iface = clearTypeParams(iface);
                  Type it = attr.attribBase(iface, baseEnv, false, true, true);
                  if (it.hasTag(CLASS)) {
+                     if (isPrimitiveClass && it.tsym == syms.cloneableType.tsym) {
+                         log.error(tree, Errors.PrimitiveClassMustNotImplementCloneable(ct));
+                     }
                      interfaces.append(it);
                      if (all_interfaces != null) all_interfaces.append(it);
                  } else {
                      if (all_interfaces == null)
                          all_interfaces = new ListBuffer<Type>().appendList(interfaces);

@@ -742,11 +747,10 @@
              }  else {
                  ct.interfaces_field = interfaces.toList();
                  ct.all_interfaces_field = (all_interfaces == null)
                          ? ct.interfaces_field : all_interfaces.toList();
              }
- 
              /* it could be that there are already some symbols in the permitted list, for the case
               * where there are subtypes in the same compilation unit but the permits list is empty
               * so don't overwrite the permitted list if it is not empty
               */
              if (!permittedSubtypeSymbols.isEmpty()) {
< prev index next >