Handle builtin types in ModuleEnvironmentSandbox.isValidHandlerDeclaration
@@ -102,9 +102,15 @@ private boolean doesSubclassMatch(Class<?> subclass, String subTypeIdentifier) {
@Override
public <T> boolean isValidTypeHandlerDeclaration(TypeInfo<T> type, TypeHandler<T> typeHandler) {
- Name moduleDeclaringType = moduleEnvironment.getModuleProviding(type.getRawType());
Name moduleDeclaringHandler = moduleEnvironment.getModuleProviding(typeHandler.getClass());
+ if (type.getRawType().getClassLoader() == null) {
+ // Modules cannot specify handlers for builtin classes
+ return moduleDeclaringHandler == null;
+ }
+
+ Name moduleDeclaringType = moduleEnvironment.getModuleProviding(type.getRawType());
+
// Both the type and the handler must come from the same module
return Objects.equals(moduleDeclaringType, moduleDeclaringHandler);
}
