aboutsummaryrefslogtreecommitdiff
path: root/src/Java/sun/repackage/ForgeEnumHelper.java
blob: 8d77877ceea4a6ff9e14dd232f65931ada596973 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package sun.repackage;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

import gtPlusPlus.core.util.reflect.ReflectionUtils;

public class ForgeEnumHelper
{
    private static Object reflectionFactory      = null;
    private static Method newConstructorAccessor = null;
    private static Method newInstance            = null;
    private static Method newFieldAccessor       = null;
    private static Method fieldAccessorSet       = null;
    private static boolean isSetup               = false;
    
    private static void setup()
    {
        if (isSetup)
        {
            return;
        }

        try
        {

        	Class aRefFac = ReflectionUtils.getClass("sun.repackage.ReflectionFactory");
        	Class aConAcc = ReflectionUtils.getClass("sun.repackage.ConstructorAccessor");
        	Class aFieAcc = ReflectionUtils.getClass("sun.repackage.FieldAccessor");

        	Method getReflectionFactory = ReflectionUtils.getMethod(aRefFac, "getReflectionFactory", new Class[] {});
        	reflectionFactory = ReflectionUtils.invoke(aRefFac, getReflectionFactory, new Object[] {});        	
        	newConstructorAccessor = ReflectionUtils.getMethod(aRefFac, "newConstructorAccessor", new Class[] {Constructor.class});
        	newFieldAccessor = ReflectionUtils.getMethod(aRefFac, "newFieldAccessor", new Class[] {Field.class, boolean.class});
        	newInstance = ReflectionUtils.getMethod(aConAcc, "newInstance", new Class[] {Object[].class});
        	fieldAccessorSet = ReflectionUtils.getMethod(aFieAcc, "set", new Class[] {Object.class, Object.class});
        	
        	
        	
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }

        isSetup = true;
    }

    static
    {
        if (!isSetup)
        {
            setup();
        }
    }
}