當前位置: 首頁>>代碼示例>>Java>>正文


Java ReflectionFactory.getReflectionFactory方法代碼示例

本文整理匯總了Java中sun.reflect.ReflectionFactory.getReflectionFactory方法的典型用法代碼示例。如果您正苦於以下問題:Java ReflectionFactory.getReflectionFactory方法的具體用法?Java ReflectionFactory.getReflectionFactory怎麽用?Java ReflectionFactory.getReflectionFactory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sun.reflect.ReflectionFactory的用法示例。


在下文中一共展示了ReflectionFactory.getReflectionFactory方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createPristineURL

import sun.reflect.ReflectionFactory; //導入方法依賴的package包/類
private static URL createPristineURL() {
    // Creates a pristine, incomplete URL object, that gets created when we
    // step into new URL(), for instance.
    ReflectionFactory rf = ReflectionFactory.getReflectionFactory();
    try {
        Constructor constructor = rf.newConstructorForSerialization(URL.class, Object.class.getDeclaredConstructor());
        Object newInstance = constructor.newInstance();
        return (URL) newInstance;
    } catch (Exception ex) {
        ex.printStackTrace();
        return null;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:MirrorValuesApp.java

示例2: createEmptyObject

import sun.reflect.ReflectionFactory; //導入方法依賴的package包/類
public static <T> Optional<T> createEmptyObject(Class<T> clazz) {
    ReflectionFactory factory = ReflectionFactory.getReflectionFactory();
    Optional<T> optional;
    try {
        Constructor objDef = Object.class.getDeclaredConstructor();
        Constructor constr = factory.newConstructorForSerialization(clazz, objDef);
        optional = Optional.ofNullable(clazz.cast(constr.newInstance()));
    } catch(NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException e) {
        e.printStackTrace();
        optional = Optional.empty();
    }
    return optional;
}
 
開發者ID:OrigamiDream,項目名稱:Leveled-Storage,代碼行數:14,代碼來源:Storages.java

示例3: getConstructor

import sun.reflect.ReflectionFactory; //導入方法依賴的package包/類
private static Constructor<?> getConstructor(Class<?> type)
    throws NoSuchMethodException
{
    ReflectionFactory factory = ReflectionFactory.getReflectionFactory();
    Constructor<?> objectConstructor = type.getConstructor((Class[]) null);

    @SuppressWarnings("unchecked")
    Constructor<?> c = (Constructor<?>) factory
            .newConstructorForSerialization(type, objectConstructor);
    return c;
}
 
開發者ID:campolake,項目名稱:openjdk9,代碼行數:12,代碼來源:NewConstructorForSerialization.java

示例4: testInternalClasses

import sun.reflect.ReflectionFactory; //導入方法依賴的package包/類
@Test
@SuppressWarnings("SpellCheckingInspection,unchecked")
public void testInternalClasses() throws Exception
{
	Object object;
	ReflectionFactory reflection = ReflectionFactory.getReflectionFactory();
	Constructor<?> constructor;
	for(Class clazz : UUIDConverter.class.getDeclaredClasses())
	{
		constructor = reflection.newConstructorForSerialization(clazz, Object.class.getDeclaredConstructor());
		object = constructor.newInstance();
		switch(clazz.getName())
		{
			case "at.pcgamingfreaks.UUIDConverter$NameChange":
				assertNotNull("The change date should not be null", clazz.getDeclaredMethod("getChangeDate").invoke(object));
				break;
			case "at.pcgamingfreaks.UUIDConverter$Profile":
				assertNotNull("The object should not be null", object);
				break;
			case "at.pcgamingfreaks.UUIDConverter$CacheData":
				SimpleDateFormat mockedDateFormat = mock(SimpleDateFormat.class);
				doThrow(new ParseException("", 0)).when(mockedDateFormat).parse(anyString());
				whenNew(SimpleDateFormat.class).withAnyArguments().thenReturn(mockedDateFormat);
				Field expiresOn = clazz.getDeclaredField("expiresOn");
				expiresOn.set(object, "2016-10-20 16:23:12 Z");
				assertNotNull("The change date should not be null", clazz.getDeclaredMethod("getExpiresDate").invoke(object));
				break;
		}
	}
}
 
開發者ID:GeorgH93,項目名稱:Bukkit_Bungee_PluginLib,代碼行數:31,代碼來源:UUIDConverterTest.java

示例5: create

import sun.reflect.ReflectionFactory; //導入方法依賴的package包/類
public static <T> T create(Class<T> clazz, Class<? super T> parent, Class<?>[] paramTypes, Object[] paramValues) throws IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException {
    if (paramTypes == null) {
        paramTypes = new Class[0];
    }
    if (paramValues == null) {
        paramValues = new Object[0];
    }
    ReflectionFactory rf = ReflectionFactory.getReflectionFactory();
    Constructor objDef = parent.getDeclaredConstructor(paramTypes);
    Constructor intConstr = rf.newConstructorForSerialization(clazz, objDef);
    return clazz.cast(intConstr.newInstance(paramValues));
}
 
開發者ID:drxaos,項目名稱:jvmvm,代碼行數:13,代碼來源:SilentObjectCreator.java

示例6: getConstructor

import sun.reflect.ReflectionFactory; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private Constructor<Object> getConstructor() {
   try {
      ReflectionFactory factory = ReflectionFactory.getReflectionFactory();
      Constructor<Object> objectConstructor =type.getConstructor((Class[]) null);
      Constructor<Object> c = (Constructor<Object>) factory.newConstructorForSerialization(type, objectConstructor);
      return c;
   } catch (Exception e) {
      throw new RuntimeException(e);
   }
}
 
開發者ID:easymock,項目名稱:objenesis,代碼行數:12,代碼來源:CreateObject.java

示例7: init

import sun.reflect.ReflectionFactory; //導入方法依賴的package包/類
@BeforeClass
static void init() {
    factory = ReflectionFactory.getReflectionFactory();
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:5,代碼來源:ReflectionFactoryTest.java

示例8: Bridge

import sun.reflect.ReflectionFactory; //導入方法依賴的package包/類
private Bridge() {
    reflectionFactory = ReflectionFactory.getReflectionFactory();
    stackWalker  = StackWalker.getInstance(
                        StackWalker.Option.RETAIN_CLASS_REFERENCE);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:6,代碼來源:Bridge.java

示例9: ObjectFactoryBuilderReflection

import sun.reflect.ReflectionFactory; //導入方法依賴的package包/類
ObjectFactoryBuilderReflection() throws NoSuchMethodException
{
  _reflectionFactory = ReflectionFactory.getReflectionFactory();
  _baseConstructor = Object.class.getDeclaredConstructor();
}
 
開發者ID:baratine,項目名稱:baratine,代碼行數:6,代碼來源:ObjectFactoryBuilderReflection.java

示例10: Bridge

import sun.reflect.ReflectionFactory; //導入方法依賴的package包/類
private Bridge()
{
    latestUserDefinedLoaderMethod = getLatestUserDefinedLoaderMethod();
    unsafe = getUnsafe() ;
    reflectionFactory = ReflectionFactory.getReflectionFactory();
}
 
開發者ID:jboss,項目名稱:openjdk-orb,代碼行數:7,代碼來源:Bridge.java


注:本文中的sun.reflect.ReflectionFactory.getReflectionFactory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。