changeset 2830:a76c663a9cac

8023974: Drop 'implements Completer' and 'implements SourceCompleter' from ClassReader resp. JavaCompiler. Reviewed-by: jjg, jfranck Contributed-by: Andreas Lundblad <andreas.lundblad@oracle.com>
author jfranck
date Thu, 05 Sep 2013 11:27:27 +0200
parents 044721d4d359
children a8c716a4a39f e32a8a29643a
files src/share/classes/com/sun/tools/javac/jvm/ClassReader.java src/share/classes/com/sun/tools/javac/main/JavaCompiler.java src/share/classes/com/sun/tools/javadoc/JavadocTool.java
diffstat 3 files changed, 32 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Wed Sep 04 14:44:05 2013 -0700
+++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Thu Sep 05 11:27:27 2013 +0200
@@ -72,7 +72,7 @@
  *  This code and its internal interfaces are subject to change or
  *  deletion without notice.</b>
  */
-public class ClassReader implements Completer {
+public class ClassReader {
     /** The context key for the class reader. */
     protected static final Context.Key<ClassReader> classReaderKey =
         new Context.Key<ClassReader>();
@@ -234,6 +234,17 @@
      */
     Set<Name> warnedAttrs = new HashSet<Name>();
 
+    /**
+     * Completer that delegates to the complete-method of this class.
+     */
+    private final Completer thisCompleter = new Completer() {
+        @Override
+        public void complete(Symbol sym) throws CompletionFailure {
+            ClassReader.this.complete(sym);
+        }
+    };
+
+
     /** Get the ClassReader instance for this invocation. */
     public static ClassReader instance(Context context) {
         ClassReader instance = context.get(classReaderKey);
@@ -264,8 +275,8 @@
         }
 
         packages.put(names.empty, syms.rootPackage);
-        syms.rootPackage.completer = this;
-        syms.unnamedPackage.completer = this;
+        syms.rootPackage.completer = thisCompleter;
+        syms.unnamedPackage.completer = thisCompleter;
     }
 
     /** Construct a new class reader, optionally treated as the
@@ -2319,7 +2330,7 @@
         ClassSymbol c = new ClassSymbol(0, name, owner);
         if (owner.kind == PCK)
             Assert.checkNull(classes.get(c.flatname), c);
-        c.completer = this;
+        c.completer = thisCompleter;
         return c;
     }
 
@@ -2389,7 +2400,7 @@
     /** Completion for classes to be loaded. Before a class is loaded
      *  we make sure its enclosing class (if any) is loaded.
      */
-    public void complete(Symbol sym) throws CompletionFailure {
+    private void complete(Symbol sym) throws CompletionFailure {
         if (sym.kind == TYP) {
             ClassSymbol c = (ClassSymbol)sym;
             c.members_field = new Scope.ErrorScope(c); // make sure it's always defined
@@ -2610,7 +2621,7 @@
             p = new PackageSymbol(
                 Convert.shortName(fullname),
                 enterPackage(Convert.packagePart(fullname)));
-            p.completer = this;
+            p.completer = thisCompleter;
             packages.put(fullname, p);
         }
         return p;
--- a/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Wed Sep 04 14:44:05 2013 -0700
+++ b/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Thu Sep 05 11:27:27 2013 +0200
@@ -80,7 +80,7 @@
  *  This code and its internal interfaces are subject to change or
  *  deletion without notice.</b>
  */
-public class JavaCompiler implements ClassReader.SourceCompleter {
+public class JavaCompiler {
     /** The context key for the compiler. */
     protected static final Context.Key<JavaCompiler> compilerKey =
         new Context.Key<JavaCompiler>();
@@ -311,6 +311,17 @@
     protected JavaCompiler delegateCompiler;
 
     /**
+     * SourceCompleter that delegates to the complete-method of this class.
+     */
+    protected final ClassReader.SourceCompleter thisCompleter =
+            new ClassReader.SourceCompleter() {
+                @Override
+                public void complete(ClassSymbol sym) throws CompletionFailure {
+                    JavaCompiler.this.complete(sym);
+                }
+            };
+
+    /**
      * Command line options.
      */
     protected Options options;
@@ -374,7 +385,7 @@
         types = Types.instance(context);
         taskListener = MultiTaskListener.instance(context);
 
-        reader.sourceCompleter = this;
+        reader.sourceCompleter = thisCompleter;
 
         options = Options.instance(context);
 
--- a/src/share/classes/com/sun/tools/javadoc/JavadocTool.java	Wed Sep 04 14:44:05 2013 -0700
+++ b/src/share/classes/com/sun/tools/javadoc/JavadocTool.java	Thu Sep 05 11:27:27 2013 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -134,7 +134,7 @@
         docenv.setEncoding(encoding);
         docenv.docClasses = docClasses;
         docenv.legacyDoclet = legacyDoclet;
-        javadocReader.sourceCompleter = docClasses ? null : this;
+        javadocReader.sourceCompleter = docClasses ? null : thisCompleter;
 
         ListBuffer<String> names = new ListBuffer<String>();
         ListBuffer<JCCompilationUnit> classTrees = new ListBuffer<JCCompilationUnit>();