aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java6
-rw-r--r--src/jdk/nashorn/internal/runtime/resources/Messages.properties1
2 files changed, 7 insertions, 0 deletions
diff --git a/src/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java b/src/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java
index 272b4ec0..f8ea9916 100644
--- a/src/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java
+++ b/src/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java
@@ -25,6 +25,7 @@
package jdk.nashorn.internal.runtime.linker;
+import java.lang.reflect.Modifier;
import jdk.internal.dynalink.CallSiteDescriptor;
import jdk.internal.dynalink.beans.BeansLinker;
import jdk.internal.dynalink.beans.StaticClass;
@@ -65,10 +66,15 @@ final class NashornStaticClassLinker implements TypeBasedGuardingDynamicLinker {
return null;
}
final Class<?> receiverClass = ((StaticClass) self).getRepresentedClass();
+
Bootstrap.checkReflectionAccess(receiverClass, true);
final CallSiteDescriptor desc = request.getCallSiteDescriptor();
// We intercept "new" on StaticClass instances to provide additional capabilities
if ("new".equals(desc.getNameToken(CallSiteDescriptor.OPERATOR))) {
+ if (! Modifier.isPublic(receiverClass.getModifiers())) {
+ throw ECMAErrors.typeError("new.on.nonpublic.javatype", receiverClass.getName());
+ }
+
// make sure new is on accessible Class
Context.checkPackageAccess(receiverClass);
diff --git a/src/jdk/nashorn/internal/runtime/resources/Messages.properties b/src/jdk/nashorn/internal/runtime/resources/Messages.properties
index 47248fce..c98c1c7c 100644
--- a/src/jdk/nashorn/internal/runtime/resources/Messages.properties
+++ b/src/jdk/nashorn/internal/runtime/resources/Messages.properties
@@ -138,6 +138,7 @@ type.error.no.method.matches.args=Can not invoke method {0} with the passed argu
type.error.method.not.constructor=Java method {0} can't be used as a constructor.
type.error.env.not.object=$ENV must be an Object.
type.error.unsupported.java.to.type=Unsupported Java.to target type {0}.
+type.error.new.on.nonpublic.javatype=new cannot be used with non-public java type {0}.
range.error.dataview.constructor.offset=Wrong offset or length in DataView constructor
range.error.dataview.offset=Offset is outside the bounds of the DataView