当前位置: 首页>>代码示例>>Java>>正文


Java ReceiverTypeDefinition类代码示例

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


ReceiverTypeDefinition类属于net.bytebuddy.dynamic.DynamicType.Builder.MethodDefinition包,在下文中一共展示了ReceiverTypeDefinition类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: extendClass

import net.bytebuddy.dynamic.DynamicType.Builder.MethodDefinition.ReceiverTypeDefinition; //导入依赖的package包/类
public static Class extendClass(Class<?> extend, final LuaTable delegations, Class<?>... inherit) {
	long startTime = System.nanoTime();

	ArrayDeque<Class> toCheck = new ArrayDeque<Class>();
	toCheck.add(extend);
	toCheck.addAll(Arrays.asList(inherit));
	extendClassWhile(toCheck, delegations);

	try {
		ReceiverTypeDefinition<?> build = b.subclass(extend).implement(inherit)
				.method(not(isConstructor()).and(isAbstract()))
				.intercept(MethodDelegation.to(new AbstractInterceptor(delegations)));
		if (!delegations.get("__new__").isnil()) {
			build = build.constructor(isConstructor()).intercept(
					SuperMethodCall.INSTANCE.andThen(MethodDelegation.to(new ConstructorInterceptor(delegations))));
		}
		Junction<MethodDescription> publicMethods = not(isConstructor().or(isAbstract())).and(isPublic())
				.and(new ElementMatcher<MethodDescription>() {
					@Override
					public boolean matches(MethodDescription target) {
						return !delegations.get(target.getName()).isnil();
					}
				});
		build = build.method(publicMethods).intercept(MethodDelegation.to(new PublicInterceptor(delegations)));

		Unloaded unloaded = build.make();
		Loaded loaded = Compatibility.get().load(unloaded);
		Class c = loaded.getLoaded();
		Log.debug("Created dynamic class " + c.getName() + " in " + ((System.nanoTime() - startTime) / 1000000)
				+ "ms");
		return c;
	} catch (Exception e) {
		Log.error("Failed to create dynamic class " + extend.getName() + " " + Arrays.toString(inherit));
		throw new CubesException("Failed to make dynamic class", e);
	}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:37,代码来源:LuaGeneration.java

示例2: extendClass

import net.bytebuddy.dynamic.DynamicType.Builder.MethodDefinition.ReceiverTypeDefinition; //导入依赖的package包/类
public static Class extendClass(Class<?> extend, final LuaTable delegations, Class<?>... inherit) {
  long startTime = System.nanoTime();

  ArrayDeque<Class> toCheck = new ArrayDeque<Class>();
  toCheck.add(extend);
  toCheck.addAll(Arrays.asList(inherit));
  while (!toCheck.isEmpty()) {
    Class check = toCheck.pop();
    for (Method method : check.getDeclaredMethods()) {
      if (Modifier.isAbstract(method.getModifiers())) {
        if (delegations.get(method.getName()).isnil())
          throw new DynamicDelegationError("No delegation for abstract method " + method);
      }
    }
    check = check.getSuperclass();
    if (check != null && check != Object.class) toCheck.add(check);
  }
  
  try {
    ReceiverTypeDefinition<?> build = b.subclass(extend).implement(inherit)
            .method(not(isConstructor()).and(isAbstract())).intercept(MethodDelegation.to(new AbstractInterceptor(delegations)));
    if (!delegations.get("__new__").isnil()) {
      build = build.constructor(isConstructor()).intercept(SuperMethodCall.INSTANCE.andThen(MethodDelegation.to(new ConstructorInterceptor(delegations))));
    }
    Junction<MethodDescription> publicMethods = not(isConstructor().or(isAbstract())).and(isPublic()).and(new ElementMatcher<MethodDescription>() {
      @Override
      public boolean matches(MethodDescription target) {
        return !delegations.get(target.getName()).isnil();
      }
    });
    build = build.method(publicMethods).intercept(MethodDelegation.to(new PublicInterceptor(delegations)));
    
    Unloaded unloaded = build.make();
    Loaded loaded = Compatibility.get().load(unloaded);
    Class c = loaded.getLoaded();
    Log.debug("Created dynamic class " + c.getName() + " in " + ((System.nanoTime() - startTime) / 1000000) + "ms");
    return c;
  } catch (Exception e) {
    Log.error("Failed to create dynamic class " + extend.getName() + " " + Arrays.toString(inherit));
    throw new CubesException("Failed to make dynamic class", e);
  }
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:43,代码来源:LuaGeneration.java


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