Merge
This commit is contained in:
commit
c4ea932612
@ -3733,17 +3733,17 @@ public class Attr extends JCTree.Visitor {
|
||||
" in tree " + tree);
|
||||
}
|
||||
|
||||
// Test (1): emit a `deprecation' warning if symbol is deprecated.
|
||||
// (for constructors, the error was given when the constructor was
|
||||
// resolved)
|
||||
// Emit a `deprecation' warning if symbol is deprecated.
|
||||
// (for constructors (but not for constructor references), the error
|
||||
// was given when the constructor was resolved)
|
||||
|
||||
if (sym.name != names.init) {
|
||||
if (sym.name != names.init || tree.hasTag(REFERENCE)) {
|
||||
chk.checkDeprecated(tree.pos(), env.info.scope.owner, sym);
|
||||
chk.checkSunAPI(tree.pos(), sym);
|
||||
chk.checkProfile(tree.pos(), sym);
|
||||
}
|
||||
|
||||
// Test (3): if symbol is a variable, check that its type and
|
||||
// If symbol is a variable, check that its type and
|
||||
// kind are compatible with the prototype and protokind.
|
||||
return check(tree, owntype, sym.kind.toSelector(), resultInfo);
|
||||
}
|
||||
|
@ -290,6 +290,13 @@ public class Resolve {
|
||||
}
|
||||
|
||||
public boolean isAccessible(Env<AttrContext> env, TypeSymbol c, boolean checkInner) {
|
||||
|
||||
/* 15.9.5.1: Note that it is possible for the signature of the anonymous constructor
|
||||
to refer to an inaccessible type
|
||||
*/
|
||||
if (env.enclMethod != null && (env.enclMethod.mods.flags & ANONCONSTR) != 0)
|
||||
return true;
|
||||
|
||||
boolean isAccessible = false;
|
||||
switch ((short)(c.flags() & AccessFlags)) {
|
||||
case PRIVATE:
|
||||
@ -301,13 +308,7 @@ public class Resolve {
|
||||
isAccessible =
|
||||
env.toplevel.packge == c.owner // fast special case
|
||||
||
|
||||
env.toplevel.packge == c.packge()
|
||||
||
|
||||
// Hack: this case is added since synthesized default constructors
|
||||
// of anonymous classes should be allowed to access
|
||||
// classes which would be inaccessible otherwise.
|
||||
env.enclMethod != null &&
|
||||
(env.enclMethod.mods.flags & ANONCONSTR) != 0;
|
||||
env.toplevel.packge == c.packge();
|
||||
break;
|
||||
default: // error recovery
|
||||
case PUBLIC:
|
||||
@ -361,6 +362,13 @@ public class Resolve {
|
||||
}
|
||||
public boolean isAccessible(Env<AttrContext> env, Type site, Symbol sym, boolean checkInner) {
|
||||
if (sym.name == names.init && sym.owner != site.tsym) return false;
|
||||
|
||||
/* 15.9.5.1: Note that it is possible for the signature of the anonymous constructor
|
||||
to refer to an inaccessible type
|
||||
*/
|
||||
if (env.enclMethod != null && (env.enclMethod.mods.flags & ANONCONSTR) != 0)
|
||||
return true;
|
||||
|
||||
switch ((short)(sym.flags() & AccessFlags)) {
|
||||
case PRIVATE:
|
||||
return
|
||||
@ -2426,7 +2434,9 @@ public class Resolve {
|
||||
return spMethod;
|
||||
}
|
||||
};
|
||||
polymorphicSignatureScope.enter(msym);
|
||||
if (!mtype.isErroneous()) { // Cache only if kosher.
|
||||
polymorphicSignatureScope.enter(msym);
|
||||
}
|
||||
return msym;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8075799
|
||||
*
|
||||
* @summary Extraneous access checks implemented by javac
|
||||
* @compile CtorAccessBypassTest.java
|
||||
* @run main CtorAccessBypassTest
|
||||
*
|
||||
*/
|
||||
|
||||
public class CtorAccessBypassTest {
|
||||
public static void main(String[] args) {
|
||||
new CtorAccessBypassTest_01<Object>(null) {};
|
||||
new CtorAccessBypassTest_01<>(null) {};
|
||||
}
|
||||
}
|
||||
|
||||
class CtorAccessBypassTest_01<T> {
|
||||
private class Private {}
|
||||
CtorAccessBypassTest_01(Private p) {
|
||||
}
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
Neg18.java:14:21: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: pkg.Neg18_01), (compiler.misc.inaccessible.varargs.type: pkg.Neg18_01.PkgPrivate, kindname.class, Neg18))
|
||||
Neg18.java:14:26: compiler.err.not.def.public.cant.access: pkg.Neg18_01.PkgPrivate, pkg.Neg18_01
|
||||
Neg18.java:14:9: compiler.err.cant.apply.symbol: kindname.constructor, , pkg.Neg18_01.PkgPrivate[], compiler.misc.no.args, kindname.class, compiler.misc.anonymous.class: <any>, (compiler.misc.inaccessible.varargs.type: pkg.Neg18_01.PkgPrivate, kindname.class, Neg18)
|
||||
2 errors
|
||||
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8130506
|
||||
* @summary javac AssertionError when invoking MethodHandle.invoke with lambda paramterer
|
||||
* @run main MethodHandleInvokeTest
|
||||
*/
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
|
||||
public class MethodHandleInvokeTest {
|
||||
|
||||
private static interface Obj2Obj {
|
||||
Object run(Object obj) throws Throwable;
|
||||
}
|
||||
|
||||
private static void m(Obj2Obj param) {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
m((obj) -> {
|
||||
MethodHandle mhandle = null;
|
||||
mhandle.invoke(obj);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
47
langtools/test/tools/javac/warnings/DeprecationSE8Test.java
Normal file
47
langtools/test/tools/javac/warnings/DeprecationSE8Test.java
Normal file
@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8065219
|
||||
* @summary Deprecated warning in method reference are missing in some cases.
|
||||
* @compile/ref=DeprecationSE8Test.noLint.out -XDrawDiagnostics DeprecationSE8Test.java
|
||||
* @compile/ref=DeprecationSE8Test.out -Xlint:deprecation,-options -source 8 -XDrawDiagnostics DeprecationSE8Test.java
|
||||
*/
|
||||
|
||||
|
||||
class DeprecationSE8Test {
|
||||
@FunctionalInterface
|
||||
interface I {
|
||||
DeprecationSE8Test meth();
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
interface J {
|
||||
int meth();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public DeprecationSE8Test() {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static int foo() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Using deprecated entities from within one's own top level class does not merit warning.
|
||||
void notBadUsages() {
|
||||
I i = DeprecationSE8Test::new;
|
||||
new DeprecationSE8Test();
|
||||
J j = DeprecationSE8Test::foo;
|
||||
foo();
|
||||
}
|
||||
}
|
||||
|
||||
class DeprecationSE8_01 {
|
||||
// Using deprecated entities from outside one's own top level class deserves warning.
|
||||
void badUsages() {
|
||||
DeprecationSE8Test.I i = DeprecationSE8Test::new;
|
||||
new DeprecationSE8Test();
|
||||
DeprecationSE8Test.foo();
|
||||
DeprecationSE8Test.J j = DeprecationSE8Test::foo;
|
||||
}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
- compiler.note.deprecated.filename: DeprecationSE8Test.java
|
||||
- compiler.note.deprecated.recompile
|
@ -0,0 +1,5 @@
|
||||
DeprecationSE8Test.java:42:34: compiler.warn.has.been.deprecated: DeprecationSE8Test(), DeprecationSE8Test
|
||||
DeprecationSE8Test.java:43:9: compiler.warn.has.been.deprecated: DeprecationSE8Test(), DeprecationSE8Test
|
||||
DeprecationSE8Test.java:44:27: compiler.warn.has.been.deprecated: foo(), DeprecationSE8Test
|
||||
DeprecationSE8Test.java:45:34: compiler.warn.has.been.deprecated: foo(), DeprecationSE8Test
|
||||
4 warnings
|
Loading…
x
Reference in New Issue
Block a user