Examples of BCClass


Examples of com.techtrader.modules.tools.bytecode.BCClass

        // Don't worry about it if there are no params.
        if (numParams == 0)
            return null;

        // Try to obtain a tt-bytecode class object
        BCClass bclass = (BCClass)ttClassCache.get(c);

        if(bclass == null) {
            try {
                bclass = new BCClass(c);
                ttClassCache.put(c, bclass);
            } catch (IOException e) {
                // what now?
            }
        }

        // Obtain the exact method we're interested in.
        BCMethod bmeth = bclass.getMethod(method.getName(),
                                          method.getParameterTypes());

        if (bmeth == null)
            return null;
View Full Code Here

Examples of serp.bytecode.BCClass

        if (proxy == null && !_proxies.containsKey(type)) {
            ClassLoader l = GeneratedClasses.getMostDerivedLoader(type,
                ProxyBean.class);
            Class pcls = loadBuildTimeProxy(type, l);
            if (pcls == null) {
                BCClass bc = generateProxyBeanBytecode(type, true);
                if (bc != null)
                    pcls = GeneratedClasses.loadBCClass(bc, l);
            }
            if (pcls != null)
                proxy = (ProxyBean) instantiateProxy(pcls,
View Full Code Here

Examples of serp.bytecode.BCClass

     */
    protected BCClass generateProxyCollectionBytecode(Class type,
        boolean runtime) {
        assertNotFinal(type);
        Project project = new Project();
        BCClass bc = project.loadClass(getProxyClassName(type, runtime));
        bc.setSuperclass(type);
        bc.declareInterface(ProxyCollection.class);
        delegateConstructors(bc, type);
        addProxyMethods(bc, false);
        addProxyCollectionMethods(bc, type);
        proxyRecognizedMethods(bc, type, ProxyCollections.class,
View Full Code Here

Examples of serp.bytecode.BCClass

     * Generate the bytecode for a map proxy for the given type.
     */
    protected BCClass generateProxyMapBytecode(Class type, boolean runtime) {
        assertNotFinal(type);
        Project project = new Project();
        BCClass bc = project.loadClass(getProxyClassName(type, runtime));
        bc.setSuperclass(type);
        bc.declareInterface(ProxyMap.class);
        delegateConstructors(bc, type);
        addProxyMethods(bc, false);
        addProxyMapMethods(bc, type);
        proxyRecognizedMethods(bc, type, ProxyMaps.class, ProxyMap.class);
View Full Code Here

Examples of serp.bytecode.BCClass

     * Generate the bytecode for a date proxy for the given type.
     */
    protected BCClass generateProxyDateBytecode(Class type, boolean runtime) {
        assertNotFinal(type);
        Project project = new Project();
        BCClass bc = project.loadClass(getProxyClassName(type, runtime));
        bc.setSuperclass(type);
        bc.declareInterface(ProxyDate.class);
        delegateConstructors(bc, type);
        addProxyMethods(bc, true);
        addProxyDateMethods(bc, type);
        proxySetters(bc, type);
View Full Code Here

Examples of serp.bytecode.BCClass

     */
    protected BCClass generateProxyCalendarBytecode(Class type,
        boolean runtime) {
        assertNotFinal(type);
        Project project = new Project();
        BCClass bc = project.loadClass(getProxyClassName(type, runtime));
        bc.setSuperclass(type);
        bc.declareInterface(ProxyCalendar.class);
        delegateConstructors(bc, type);
        addProxyMethods(bc, true);
        addProxyCalendarMethods(bc, type);
        proxySetters(bc, type);
View Full Code Here

Examples of serp.bytecode.BCClass

            if (cons == null)
                return null;
        }

        Project project = new Project();
        BCClass bc = project.loadClass(getProxyClassName(type, runtime));
        bc.setSuperclass(type);
        bc.declareInterface(ProxyBean.class);
        delegateConstructors(bc, type);
        addProxyMethods(bc, true);
        addProxyBeanMethods(bc, type, cons);
        if (!proxySetters(bc, type))
View Full Code Here

Examples of serp.bytecode.BCClass

            }));
        }

        ProxyManagerImpl mgr = new ProxyManagerImpl();
        Class cls;
        BCClass bc;
        for (int i = 0; i < types.size(); i++) {
            cls = Class.forName((String) types.get(i));
            try {
                if (Class.forName(getProxyClassName(cls, false), true,
                    GeneratedClasses.getMostDerivedLoader(cls, Proxy.class))
                    != null)
                    continue;
            } catch (Throwable t) {
                // expected if the class hasn't been generated
            }

            if (Collection.class.isAssignableFrom(cls))
                bc = mgr.generateProxyCollectionBytecode(cls, false);        
            else if (Map.class.isAssignableFrom(cls))
                bc = mgr.generateProxyMapBytecode(cls, false);        
            else if (Date.class.isAssignableFrom(cls))
                bc = mgr.generateProxyDateBytecode(cls, false);
            else if (Calendar.class.isAssignableFrom(cls))
                bc = mgr.generateProxyCalendarBytecode(cls, false);
            else
                bc = mgr.generateProxyBeanBytecode(cls, false);

            System.out.println(bc.getName());
            bc.write(new File(dir, bc.getClassName() + ".class"));
        }
    }
View Full Code Here

Examples of serp.bytecode.BCClass

        throws IOException {
        Project project = new Project();
       
        InputStream in = WASManagedRuntime.class.getClassLoader()
            .getResourceAsStream(CLASS.replace('.', '/') + ".class");
        BCClass bcClass = project.loadClass(in);
       
        String [] interfaces = bcClass.getInterfaceNames();
       
        if(interfaces != null) {
          for(int i = 0; i < interfaces.length; i++) {
            if(interfaces[i].equals(INTERFACE)) {
              return;
            }
          }
        }
        bcClass.declareInterface(INTERFACE);
        bcClass.write();
    }
View Full Code Here

Examples of serp.bytecode.BCClass

    /**
     * Generate a new class with the given name. If a non-null parent class
     * is given, it will be set as the superclass.
     */
    public Class generateClass(String name, Class parent) {
        BCClass bc = _project.loadClass(name, null);
        if (parent != null)
            bc.setSuperclass(parent);
        bc.addDefaultConstructor();

        try {
            return Class.forName(name, false, _loader);
        } catch (ClassNotFoundException cnfe) {
            throw new InternalException(cnfe.toString(), cnfe);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.