Java: Inspection to check that qualified names in Class.forName() belongs to exported or open package (IDEA-167271)

This commit is contained in:
Pavel Dolgov
2017-04-18 15:43:26 +03:00
parent 961d4e1cb3
commit 844082c455
13 changed files with 283 additions and 18 deletions
@@ -0,0 +1,9 @@
package my.main;
class Main {
void foo() throws Exception {
Class.forName("my.api.Api");
Class.forName(<warning descr="The module 'API' does not export the package 'my.impl' to the module 'MAIN'">"my.impl.Impl"</warning>);
Class.forName(<warning descr="The module 'API' does not open the package 'my.api' to the module 'MAIN'">"my.api.PackageLocal"</warning>);
}
}
@@ -0,0 +1,8 @@
package my.main;
class Main {
void foo() throws Exception {
Class.forName(<warning descr="The module 'MAIN' does not have the module 'API' in requirements">"my.api.Api"</warning>);
Class.forName(<warning descr="The module 'MAIN' does not have the module 'API' in requirements">"my.impl.Impl"</warning>);
}
}
@@ -0,0 +1,8 @@
package my.main;
class Main {
void foo() throws Exception {
Class.forName("my.api.Api");
Class.forName("my.impl.Impl");
}
}
@@ -0,0 +1,8 @@
package my.main;
class Main {
void foo() throws Exception {
Class.forName("my.api.Api");
Class.forName(<warning descr="The module 'API' does not export the package 'my.impl' to the module 'MAIN'">"my.impl.Impl"</warning>);
}
}