Package serp.bytecode

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


     */
    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

     * 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

     * 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

     */
    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

            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

            }));
        }

        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

        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

    /**
     * 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

                continue;
            }
           
            meth = (Method) fmds[i].getBackingMember();
            // ##### this will fail if we override and don't call super.
            BCClass declaringType = _managedType.getProject()
                .loadClass(fmds[i].getDeclaringType());
            getter = declaringType.getDeclaredMethod(meth.getName(),
                meth.getParameterTypes());
            if (getter == null) {
                addViolation("property-no-getter", new Object[]{ fmds[i] },
                    true);
                continue;
            }
            returned = getReturnedField(getter);
            if (returned != null)
                registerBackingFieldInfo(fmds[i], getter, returned);

            setter = declaringType.getDeclaredMethod(getSetterName(fmds[i]),
                new Class[]{ fmds[i].getDeclaredType() });
            if (setter == null) {
                if (returned == null) {
                    addViolation("property-no-setter",
                        new Object[]{ fmds[i] }, true);
View Full Code Here

TOP

Related Classes of serp.bytecode.BCClass

Copyright © 2018 www.massapicom. 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.