JDK-8037388 : Invocation of protected method of base class does not compile
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: os_x
  • CPU: x86
  • Submitted: 2014-03-12
  • Updated: 2014-08-28
  • Resolved: 2014-06-30
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b15Resolved
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Darwin alexbool-osx 13.1.0 Darwin Kernel Version 13.1.0: Thu Jan 16 19:40:37 PST 2014; root:xnu-2422.90.20~2/RELEASE_X86_64 x86_64

A DESCRIPTION OF THE PROBLEM :
Under certain circumctances, javac 8 rejects to compile code that compiles under previous versions of javac. In the given example, if non-compiling line is modified to "return this.eq(this.value, value);" or "return super.eq(this.value, value);", the problem goes away.

REGRESSION.  Last worked in version 7u51


ERROR MESSAGES/STACK TRACES THAT OCCUR :
 error: no enclosing instance of type AbstractMapF is in scope

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.util.AbstractMap;

public class Jdk8Test {

    public static abstract class SingletonMap<K, V> extends AbstractMapF<K, V> {

        private final K key;
        private final V value;

        public SingletonMap(K key, V value) {
            this.key = key;
            this.value = value;
        }

        @Override
        public boolean containsValue(Object value) {
            return eq(this.value, value); // does not compile
        }
    }

    public static abstract class AbstractMapF<K, V> extends AbstractMap<K, V> {
        protected boolean eq(Object a, Object b) {
            return true;
        }
    }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Qualifying instance on which method eq is invoked helps: either "this.eq(...)" or "super.eq(...)" compiles fine.