You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2022/04/19 07:56:52 UTC
[groovy] 07/11: minor refactor: reduce removal warnings
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch GROOVY_4_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 1b2d65f1f349a4334b598de0e1a6da0fb3b0f564
Author: Paul King <pa...@asert.com.au>
AuthorDate: Sun Apr 17 22:18:22 2022 +1000
minor refactor: reduce removal warnings
---
src/main/java/groovy/lang/GroovyClassLoader.java | 1 +
src/main/java/groovy/lang/GroovyCodeSource.java | 1 +
src/main/java/groovy/lang/GroovyShell.java | 1 +
.../groovy/reflection/AccessPermissionChecker.java | 14 +++++++-------
.../org/codehaus/groovy/reflection/ReflectionUtils.java | 1 +
.../groovy/reflection/stdclasses/CachedSAMClass.java | 1 +
6 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/src/main/java/groovy/lang/GroovyClassLoader.java b/src/main/java/groovy/lang/GroovyClassLoader.java
index 704d5f70cf..cb154007f2 100644
--- a/src/main/java/groovy/lang/GroovyClassLoader.java
+++ b/src/main/java/groovy/lang/GroovyClassLoader.java
@@ -831,6 +831,7 @@ public class GroovyClassLoader extends URLClassLoader {
* @throws ClassNotFoundException if the class could not be found
* @throws CompilationFailedException if the source file could not be compiled
*/
+ @SuppressWarnings("removal") // TODO a future Groovy version should remove the security check
public Class loadClass(final String name, boolean lookupScriptFiles, boolean preferClassOverScript, boolean resolve)
throws ClassNotFoundException, CompilationFailedException {
// look into cache
diff --git a/src/main/java/groovy/lang/GroovyCodeSource.java b/src/main/java/groovy/lang/GroovyCodeSource.java
index 721c55562d..f5adac93c2 100644
--- a/src/main/java/groovy/lang/GroovyCodeSource.java
+++ b/src/main/java/groovy/lang/GroovyCodeSource.java
@@ -232,6 +232,7 @@ public class GroovyCodeSource {
return cachable;
}
+ @SuppressWarnings("removal") // TODO a future Groovy version should remove the security check
private static CodeSource createCodeSource(final String codeBase) {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
diff --git a/src/main/java/groovy/lang/GroovyShell.java b/src/main/java/groovy/lang/GroovyShell.java
index 57fa108c60..fc2b3f7ed5 100644
--- a/src/main/java/groovy/lang/GroovyShell.java
+++ b/src/main/java/groovy/lang/GroovyShell.java
@@ -455,6 +455,7 @@ public class GroovyShell extends GroovyObjectSupport {
* Evaluates some script against the current Binding and returns the result.
* The .class file created from the script is given the supplied codeBase
*/
+ @SuppressWarnings("removal") // TODO a future Groovy version should skip security checks
public Object evaluate(final String scriptText, final String fileName, final String codeBase) throws CompilationFailedException {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
diff --git a/src/main/java/org/codehaus/groovy/reflection/AccessPermissionChecker.java b/src/main/java/org/codehaus/groovy/reflection/AccessPermissionChecker.java
index ae297dfd09..7e0f8f2b2e 100644
--- a/src/main/java/org/codehaus/groovy/reflection/AccessPermissionChecker.java
+++ b/src/main/java/org/codehaus/groovy/reflection/AccessPermissionChecker.java
@@ -25,8 +25,8 @@ import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.ReflectPermission;
-import java.security.AccessControlException;
+@SuppressWarnings("removal") // TODO future Groovy versions should deprecate then remove this class
final class AccessPermissionChecker {
private static final ReflectPermission REFLECT_PERMISSION = new ReflectPermission("suppressAccessChecks");
@@ -55,7 +55,7 @@ final class AccessPermissionChecker {
static void checkAccessPermission(Method method) {
try {
checkAccessPermission(method.getDeclaringClass(), method.getModifiers(), method.isAccessible());
- } catch (AccessControlException e) {
+ } catch (java.security.AccessControlException e) {
throw createCacheAccessControlExceptionOf(method, e);
}
}
@@ -63,19 +63,19 @@ final class AccessPermissionChecker {
static void checkAccessPermission(Constructor constructor) {
try {
checkAccessPermission(constructor.getDeclaringClass(), constructor.getModifiers(), constructor.isAccessible());
- } catch (AccessControlException e) {
+ } catch (java.security.AccessControlException e) {
throw createCacheAccessControlExceptionOf(constructor, e);
}
}
- private static CacheAccessControlException createCacheAccessControlExceptionOf(Method method, AccessControlException e) {
+ private static CacheAccessControlException createCacheAccessControlExceptionOf(Method method, java.security.AccessControlException e) {
return new CacheAccessControlException(
"Groovy object can not access method " + method.getName()
+ " cacheAccessControlExceptionOf class " + method.getDeclaringClass().getName()
+ " with modifiers \"" + Modifier.toString(method.getModifiers()) + "\"", e);
}
- private static CacheAccessControlException createCacheAccessControlExceptionOf(Constructor constructor, AccessControlException e) {
+ private static CacheAccessControlException createCacheAccessControlExceptionOf(Constructor constructor, java.security.AccessControlException e) {
return new CacheAccessControlException(
"Groovy object can not access constructor " + constructor.getName()
+ " cacheAccessControlExceptionOf class " + constructor.getDeclaringClass().getName()
@@ -85,12 +85,12 @@ final class AccessPermissionChecker {
static void checkAccessPermission(Field field) {
try {
checkAccessPermission(field.getDeclaringClass(), field.getModifiers(), field.isAccessible());
- } catch (AccessControlException e) {
+ } catch (java.security.AccessControlException e) {
throw createCacheAccessControlExceptionOf(field, e);
}
}
- private static CacheAccessControlException createCacheAccessControlExceptionOf(Field field, AccessControlException e) {
+ private static CacheAccessControlException createCacheAccessControlExceptionOf(Field field, java.security.AccessControlException e) {
return new CacheAccessControlException(
"Groovy object can not access field " + field.getName()
+ " cacheAccessControlExceptionOf class " + field.getDeclaringClass().getName()
diff --git a/src/main/java/org/codehaus/groovy/reflection/ReflectionUtils.java b/src/main/java/org/codehaus/groovy/reflection/ReflectionUtils.java
index 13d29ab536..f5e662af6e 100644
--- a/src/main/java/org/codehaus/groovy/reflection/ReflectionUtils.java
+++ b/src/main/java/org/codehaus/groovy/reflection/ReflectionUtils.java
@@ -272,6 +272,7 @@ public class ReflectionUtils {
|| extraIgnoredPackages.contains(c.getPackage().getName())))));
}
+ @SuppressWarnings("removal") // TODO a future Groovy version should deprecate this class
private static class ClassContextHelper extends SecurityManager {
@Override
public Class[] getClassContext() {
diff --git a/src/main/java/org/codehaus/groovy/reflection/stdclasses/CachedSAMClass.java b/src/main/java/org/codehaus/groovy/reflection/stdclasses/CachedSAMClass.java
index d131a98302..7941235eb8 100644
--- a/src/main/java/org/codehaus/groovy/reflection/stdclasses/CachedSAMClass.java
+++ b/src/main/java/org/codehaus/groovy/reflection/stdclasses/CachedSAMClass.java
@@ -100,6 +100,7 @@ public class CachedSAMClass extends CachedClass {
}
}
+ @SuppressWarnings("removal") // TODO a future Groovy version should remove the security check
private static Method[] getDeclaredMethods(final Class c) {
try {
Method[] methods = VMPluginFactory.getPlugin().doPrivileged((PrivilegedAction<Method[]>) c::getDeclaredMethods);