• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java StaticClass类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中jdk.internal.dynalink.beans.StaticClass的典型用法代码示例。如果您正苦于以下问题:Java StaticClass类的具体用法?Java StaticClass怎么用?Java StaticClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



StaticClass类属于jdk.internal.dynalink.beans包,在下文中一共展示了StaticClass类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createProperty

import jdk.internal.dynalink.beans.StaticClass; //导入依赖的package包/类
private Object createProperty(final String name) {
    final int len = args.length;

    for (int i = len - 1; i > -1; i--) {
        final Object obj = args[i];

        if (obj instanceof StaticClass) {
            if (((StaticClass)obj).getRepresentedClass().getSimpleName().equals(name)) {
                return obj;
            }
        } else if (obj instanceof NativeJavaPackage) {
            final String pkgName  = ((NativeJavaPackage)obj).getName();
            final String fullName = pkgName.isEmpty() ? name : (pkgName + "." + name);
            final Context context = Global.instance().getContext();
            try {
                return StaticClass.forClass(context.findClass(fullName));
            } catch (final ClassNotFoundException e) {
                // IGNORE
            }
        }
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:NativeJavaImporter.java


示例2: getInstanceAdapterClass

import jdk.internal.dynalink.beans.StaticClass; //导入依赖的package包/类
private StaticClass getInstanceAdapterClass(final ProtectionDomain protectionDomain) {
    CodeSource codeSource = protectionDomain.getCodeSource();
    if(codeSource == null) {
        codeSource = MINIMAL_PERMISSION_DOMAIN.getCodeSource();
    }
    StaticClass instanceAdapterClass = instanceAdapters.get(codeSource);
    if(instanceAdapterClass != null) {
        return instanceAdapterClass;
    }
    // Any "unknown source" code source will default to no permission domain.
    final ProtectionDomain effectiveDomain = codeSource.equals(MINIMAL_PERMISSION_DOMAIN.getCodeSource()) ?
            MINIMAL_PERMISSION_DOMAIN : protectionDomain;

    instanceAdapterClass = instanceAdapterGenerator.generateClass(commonLoader, effectiveDomain);
    final StaticClass existing = instanceAdapters.putIfAbsent(codeSource, instanceAdapterClass);
    return existing == null ? instanceAdapterClass : existing;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:JavaAdapterFactory.java


示例3: INSTANCEOF

import jdk.internal.dynalink.beans.StaticClass; //导入依赖的package包/类
/**
 * ECMA 11.8.6 - The strict instanceof operator - generic implementation
 *
 * @param obj first object to compare
 * @param clazz type to check against
 *
 * @return true if {@code obj} is an instanceof {@code clazz}
 */
public static boolean INSTANCEOF(final Object obj, final Object clazz) {
    if (clazz instanceof ScriptFunction) {
        if (obj instanceof ScriptObject) {
            return ((ScriptObject)clazz).isInstance((ScriptObject)obj);
        }
        return false;
    }

    if (clazz instanceof StaticClass) {
        return ((StaticClass)clazz).getRepresentedClass().isInstance(obj);
    }

    if (clazz instanceof JSObject) {
        return ((JSObject)clazz).isInstance(obj);
    }

    // provide for reverse hook
    if (obj instanceof JSObject) {
        return ((JSObject)obj).isInstanceOf(clazz);
    }

    throw typeError("instanceof.on.non.object");
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:32,代码来源:ScriptRuntime.java


示例4: generateDynamicListener

import jdk.internal.dynalink.beans.StaticClass; //导入依赖的package包/类
public Object generateDynamicListener(Map<StaticClass, Set<Consumer<? extends Event>>> map) {
	Object o = null;
	try {
		byte[] b = generateDynamicListenerbc(map);
		o = loadClass("cz.neumimto.rpg.listeners.DynamicListener", b);
		Class<?> listener = Class.forName("cz.neumimto.rpg.listeners.DynamicListener");
		o = listener.newInstance();
		for (Field field : listener.getDeclaredFields()) {
			if (Set.class.isAssignableFrom(field.getType())) {
				Set s = (Set) field.get(o);
				ParameterizedType paramtype = (ParameterizedType) field.getGenericType();
				ParameterizedType type = (ParameterizedType) paramtype.getActualTypeArguments()[0];
				Class<? extends Event> event = (Class<? extends Event>) type.getActualTypeArguments()[0];
				map.entrySet().stream()
						.filter(m -> m.getKey().getRepresentedClass() == event)
						.forEach(a -> s.addAll(a.getValue()));
			}
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
	return o;
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:24,代码来源:ClassGenerator.java


示例5: noSuchProperty

import jdk.internal.dynalink.beans.StaticClass; //导入依赖的package包/类
/**
 * Handle creation of new attribute.
 * @param desc the call site descriptor
 * @param request the link request
 * @return Link to be invoked at call site.
 */
@Override
public GuardedInvocation noSuchProperty(final CallSiteDescriptor desc, final LinkRequest request) {
    final String propertyName = desc.getNameToken(2);
    final String fullName     = name.isEmpty() ? propertyName : name + "." + propertyName;

    final Context context = Context.getContextTrusted();

    Class<?> javaClass = null;
    try {
        javaClass = context.findClass(fullName);
    } catch (final NoClassDefFoundError | ClassNotFoundException e) {
        //ignored
    }

    if (javaClass == null) {
        set(propertyName, new NativeJavaPackage(fullName, getProto()), false);
    } else {
        set(propertyName, StaticClass.forClass(javaClass), false);
    }

    return super.lookup(desc, request);
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:29,代码来源:NativeJavaPackage.java


示例6: createProperty

import jdk.internal.dynalink.beans.StaticClass; //导入依赖的package包/类
private Object createProperty(final String name) {
    final int len = args.length;

    for (int i = len - 1; i > -1; i--) {
        final Object obj = args[i];

        if (obj instanceof StaticClass) {
            if (((StaticClass)obj).getRepresentedClass().getSimpleName().equals(name)) {
                return obj;
            }
        } else if (obj instanceof NativeJavaPackage) {
            final String pkgName  = ((NativeJavaPackage)obj).getName();
            final String fullName = pkgName.isEmpty() ? name : (pkgName + "." + name);
            try {
                return StaticClass.forClass(Class.forName(fullName));
            } catch (final ClassNotFoundException e) {
                // IGNORE
            }
        }
    }
    return null;
}
 
开发者ID:wro4j,项目名称:nashorn-backport,代码行数:23,代码来源:NativeJavaImporter.java


示例7: convert

import jdk.internal.dynalink.beans.StaticClass; //导入依赖的package包/类
/**
 * Convert the given object to the given type.
 *
 * @param obj object to be converted
 * @param type destination type to convert to
 * @return converted object
 */
public static Object convert(final Object obj, final Object type) {
    if (obj == null) {
        return null;
    }

    final Class<?> clazz;
    if (type instanceof Class) {
        clazz = (Class<?>)type;
    } else if (type instanceof StaticClass) {
        clazz = ((StaticClass)type).getRepresentedClass();
    } else {
        throw new IllegalArgumentException("type expected");
    }

    final LinkerServices linker = Bootstrap.getLinkerServices();
    final Object objToConvert = unwrap(obj);
    final MethodHandle converter = linker.getTypeConverter(objToConvert.getClass(),  clazz);
    if (converter == null) {
        // no supported conversion!
        throw new UnsupportedOperationException("conversion not supported");
    }

    try {
        return converter.invoke(objToConvert);
    } catch (final RuntimeException | Error e) {
        throw e;
    } catch (final Throwable t) {
        throw new RuntimeException(t);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:38,代码来源:ScriptUtils.java


示例8: typeName

import jdk.internal.dynalink.beans.StaticClass; //导入依赖的package包/类
/**
 * Returns name of a java type {@link StaticClass}.
 * @param self not used
 * @param type the type whose name is returned
 * @return name of the given type
 */
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static Object typeName(final Object self, final Object type) {
    if (type instanceof StaticClass) {
        return ((StaticClass)type).getRepresentedClass().getName();
    } else if (type instanceof Class) {
        return ((Class<?>)type).getName();
    } else {
        return UNDEFINED;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:NativeJava.java


示例9: getAdapterClassFor

import jdk.internal.dynalink.beans.StaticClass; //导入依赖的package包/类
private static StaticClass getAdapterClassFor(final Class<?>[] types, final ScriptObject classOverrides, final ProtectionDomain protectionDomain) {
    assert types != null && types.length > 0;
    final SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        for (final Class<?> type : types) {
            // check for restricted package access
            Context.checkPackageAccess(type);
            // check for classes, interfaces in reflection
            ReflectionCheckLinker.checkReflectionAccess(type, true);
        }
    }
    return getAdapterInfo(types).getAdapterClass(classOverrides, protectionDomain);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:JavaAdapterFactory.java


示例10: getAdapterClass

import jdk.internal.dynalink.beans.StaticClass; //导入依赖的package包/类
StaticClass getAdapterClass(final ScriptObject classOverrides, final ProtectionDomain protectionDomain) {
    if(adaptationResult.getOutcome() != AdaptationResult.Outcome.SUCCESS) {
        throw adaptationResult.typeError();
    }
    return classOverrides == null ? getInstanceAdapterClass(protectionDomain) :
        getClassAdapterClass(classOverrides, protectionDomain);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:JavaAdapterFactory.java


示例11: getClassAdapterClass

import jdk.internal.dynalink.beans.StaticClass; //导入依赖的package包/类
private StaticClass getClassAdapterClass(final ScriptObject classOverrides, final ProtectionDomain protectionDomain) {
    JavaAdapterServices.setClassOverrides(classOverrides);
    try {
        return classAdapterGenerator.generateClass(commonLoader, protectionDomain);
    } finally {
        JavaAdapterServices.setClassOverrides(null);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:JavaAdapterFactory.java


示例12: isCallable

import jdk.internal.dynalink.beans.StaticClass; //导入依赖的package包/类
/**
 * Returns if the given object is a "callable"
 * @param obj object to be checked for callability
 * @return true if the obj is callable
 */
public static boolean isCallable(final Object obj) {
    if (obj == ScriptRuntime.UNDEFINED || obj == null) {
        return false;
    }

    return obj instanceof ScriptFunction ||
        isJSObjectFunction(obj) ||
        BeansLinker.isDynamicMethod(obj) ||
        obj instanceof BoundCallable ||
        isFunctionalInterfaceObject(obj) ||
        obj instanceof StaticClass;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:Bootstrap.java


示例13: isStrictCallable

import jdk.internal.dynalink.beans.StaticClass; //导入依赖的package包/类
/**
 * Returns true if the given object is a strict callable
 * @param callable the callable object to be checked for strictness
 * @return true if the obj is a strict callable, false if it is a non-strict callable.
 * @throws ECMAException with {@code TypeError} if the object is not a callable.
 */
public static boolean isStrictCallable(final Object callable) {
    if (callable instanceof ScriptFunction) {
        return ((ScriptFunction)callable).isStrict();
    } else if (isJSObjectFunction(callable)) {
        return ((JSObject)callable).isStrictFunction();
    } else if (callable instanceof BoundCallable) {
        return isStrictCallable(((BoundCallable)callable).getCallable());
    } else if (BeansLinker.isDynamicMethod(callable) || callable instanceof StaticClass) {
        return false;
    }
    throw notFunction(callable);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:Bootstrap.java


示例14: getGuardedInvocation

import jdk.internal.dynalink.beans.StaticClass; //导入依赖的package包/类
@Override
public GuardedInvocation getGuardedInvocation(final LinkRequest linkRequest, final LinkerServices linkerServices) throws Exception {
    final LinkRequest request = linkRequest.withoutRuntimeContext(); // Nashorn has no runtime context
    final Object self = request.getReceiver();
    if (self.getClass() != StaticClass.class) {
        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);

        // Is the class abstract? (This includes interfaces.)
        if (NashornLinker.isAbstractClass(receiverClass)) {
            // Change this link request into a link request on the adapter class.
            final Object[] args = request.getArguments();
            args[0] = JavaAdapterFactory.getAdapterClassFor(new Class<?>[] { receiverClass }, null,
                    linkRequest.getCallSiteDescriptor().getLookup());
            final LinkRequest adapterRequest = request.replaceArguments(request.getCallSiteDescriptor(), args);
            final GuardedInvocation gi = checkNullConstructor(delegate(linkerServices, adapterRequest), receiverClass);
            // Finally, modify the guard to test for the original abstract class.
            return gi.replaceMethods(gi.getInvocation(), Guards.getIdentityGuard(self));
        }
        // If the class was not abstract, just delegate linking to the standard StaticClass linker. Make an
        // additional check to ensure we have a constructor. We could just fall through to the next "return"
        // statement, except we also insert a call to checkNullConstructor() which throws an ECMAScript TypeError
        // with a more intuitive message when no suitable constructor is found.
        return checkNullConstructor(delegate(linkerServices, request), receiverClass);
    }
    // In case this was not a "new" operation, just delegate to the the standard StaticClass linker.
    return delegate(linkerServices, request);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:41,代码来源:NashornStaticClassLinker.java


示例15: generateClass

import jdk.internal.dynalink.beans.StaticClass; //导入依赖的package包/类
/**
 * Loads the generated adapter class into the JVM.
 * @param parentLoader the parent class loader for the generated class loader
 * @param protectionDomain the protection domain for the generated class
 * @return the generated adapter class
 */
StaticClass generateClass(final ClassLoader parentLoader, final ProtectionDomain protectionDomain) {
    assert protectionDomain != null;
    return AccessController.doPrivileged(new PrivilegedAction<StaticClass>() {
        @Override
        public StaticClass run() {
            try {
                return StaticClass.forClass(Class.forName(className, true, createClassLoader(parentLoader, protectionDomain)));
            } catch (final ClassNotFoundException e) {
                throw new AssertionError(e); // cannot happen
            }
        }
    }, CREATE_LOADER_ACC_CTXT);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:JavaAdapterClassLoader.java


示例16: isStatic

import jdk.internal.dynalink.beans.StaticClass; //导入依赖的package包/类
public boolean isStatic(Object cls) {
    if (cls == null) {
        return false;
    }
    //jdk.internal.dynalink.beans.StaticClass
    if (cls instanceof StaticClass) {
        return true;
    }
    return false;
}
 
开发者ID:StallionCMS,项目名称:stallion-core,代码行数:11,代码来源:JavaToJsHelpers.java



注:本文中的jdk.internal.dynalink.beans.StaticClass类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IActionDelegate2类代码示例发布时间:2022-05-22
下一篇:
Java SolrRequestHandler类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap