Examples of ClassGen


Examples of org.apache.bcel.generic.ClassGen

        String[] interfaceNames = new String[interfaces.length + 1];
        for (int i = 0; i < interfaces.length; i++)
            interfaceNames[i] = interfaces[i].getName();
        interfaceNames[interfaces.length] = Stub.class.getName();

        ClassGen newStubClass = new ClassGen(className, superClassName,
                "generated", // file name
                Constants.ACC_PUBLIC | Constants.ACC_FINAL, interfaceNames);

        ConstantPoolGen cp = newStubClass.getConstantPool();

        if (handlerMethodRef == null)
            throw new IllegalArgumentException("handler method is null");

        //
        // Check that the handler method is valid
        //
        Class[] paramTypes = handlerMethodRef.getParameterTypes();
        if (paramTypes.length != 3) {
            throw new IllegalArgumentException(
                    "handler method must have three arguments");
        }

        if (!paramTypes[0].isAssignableFrom(superClass)) {
            throw new IllegalArgumentException(
                    "Handler's 1st argument must be super-type for "
                            + superClass);
        }

        // the type of data fields
        Type typeOfDataFields = translate(paramTypes[1]);

        if (Object[].class != paramTypes[2]) {
            throw new IllegalArgumentException(
                    "Handler's 3rd argument must be Object[]");
        }

        //
        // Construct field for the handler reference
        //
        Class handlerClass = handlerMethodRef.getDeclaringClass();
        FieldGen handlerFieldGen = new FieldGen(Constants.ACC_PRIVATE
                | Constants.ACC_FINAL, translate(handlerClass), Util
                .handlerFieldName(), cp);
        newStubClass.addField(handlerFieldGen.getField());

        //
        // Construct the method that gets the stub handler.
        //
        generateHandlerGetter(newStubClass, handlerFieldGen);

        //
        // Emit constructor
        //
        emitOneArgConstructor(newStubClass, handlerFieldGen);

        //
        // Construct data fields
        //
        FieldGen[] dataFieldGens = new FieldGen[methods.length];
        for (int i = 0; i < methods.length; i++) {
            MethodRef method = methods[i];

            dataFieldGens[i] = new FieldGen(Constants.ACC_PRIVATE
                    | Constants.ACC_STATIC, typeOfDataFields, Util
                    .methodFieldName(i), cp);

            newStubClass.addField(dataFieldGens[i].getField());
        }

        //
        // Construct method stubs
        //
        for (int i = 0; i < methods.length; i++) {
            generate(newStubClass, methods[i], dataFieldGens[i],
                    handlerFieldGen, handlerMethodRef);
        }

        JavaClass javaClass = newStubClass.getJavaClass();
        byte[] classData = javaClass.getBytes();

        try {
            if (Boolean.getBoolean("org.apache.yoko.rmi.util.stub.debug")) {
                java.io.File out = new java.io.File(className + ".class");
View Full Code Here

Examples of org.apache.bcel.generic.ClassGen

     *
     * @return byte code
     */
    private static byte[] createSubClassByteCode(final String className)
    {
        ClassGen classGen = new ClassGen(className,
                AbstractLDAPSSLSocketFactory.class.getName(),
                "<generated>",
                ACC_PUBLIC | ACC_SUPER,
                null);
        ConstantPoolGen constantPoolGen = classGen.getConstantPool();
        InstructionFactory factory = new InstructionFactory(classGen);

        createSslContextStaticField(classGen, constantPoolGen);
        createGetDefaultStaticMethod(classGen, constantPoolGen, factory);

        classGen.addEmptyConstructor(Constants.ACC_PROTECTED);

        JavaClass javaClass = classGen.getJavaClass();
        ByteArrayOutputStream out = null;
        try
        {
            out = new ByteArrayOutputStream();
            javaClass.dump(out);
View Full Code Here

Examples of org.apache.bcel.generic.ClassGen

    RSField myplayer = data.getProperField("MyPlayer");
    RSField pixelX = data.getProperField("PixelX");
    RSField pixelY = data.getProperField("PixelY");
        for (Entry<String, ClassGen> c : classes.entrySet()) {
            for (Method m : c.getValue().getMethods()) {
              ClassGen cg = new ClassGen(c.getValue().getJavaClass());
              ConstantPoolGen cpg = c.getValue().getConstantPool();
              MethodGen gen = new MethodGen(m, c.getValue().getClassName(), cpg);
              InstructionList list = gen.getInstructionList();
              if(list == null)
                continue;
View Full Code Here

Examples of org.apache.bcel.generic.ClassGen

public class NodeNext extends Search{

  public String findNextNode(RSClient data, HashMap<String, ClassGen> classes){
    RSClass nodeClass = data.getProperClass("Node");
    for(Entry<String, ClassGen> c : classes.entrySet()){
      ClassGen cg = new ClassGen(c.getValue().getJavaClass());
      ConstantPoolGen cpg = c.getValue().getConstantPool();
      for(Method m : c.getValue().getMethods()){
        MethodSearcher mS = new MethodSearcher(m, cg, cpg);
        if(m.isSynchronized() && m.isFinal() && m.getReturnType().equals(Type.VOID)
            && mS.getTypeCount("int[]") == 1){
View Full Code Here

Examples of org.apache.bcel.generic.ClassGen

  public SearchResult run(RSClient data, HashMap<String, ClassGen> classes) {
    RSClass player = data.getProperClass("Player");
    RSClass character = data.getProperClass("Character");
        for (Entry<String, ClassGen> c : classes.entrySet()) {
            for (Method m : c.getValue().getMethods()) {
              ClassGen cg = new ClassGen(c.getValue().getJavaClass());
              ConstantPoolGen cpg = c.getValue().getConstantPool();
                MethodGen gen = new MethodGen(m, c.getValue().getClassName(), cpg);
                MethodSearcher mS = new MethodSearcher(m, cg, cpg);
              if(m.isFinal() && m.isStatic() && m.getReturnType().equals(Type.VOID) &&
                  mS.getArgCount() == 4 && mS.getTypeCount(player.className) == 1){
View Full Code Here

Examples of org.apache.bcel.generic.ClassGen

public class NodeListHead extends Search{

  public String getNodeListClass(RSClient data, HashMap<String, ClassGen> classes) {
        for (Entry<String, ClassGen> c : classes.entrySet()) {
          ClassGen cg = new ClassGen(c.getValue().getJavaClass());
          ConstantPoolGen cpg = c.getValue().getConstantPool();
          RSClass renderClass = data.getProperClass("Toolkit");
          RSClass sdToolkit = data.getProperClass("SDToolkit");
          if(sdToolkit == null || renderClass == null)
            return null;
View Full Code Here

Examples of org.apache.bcel.generic.ClassGen

 
  public SearchResult run(RSClient data, HashMap<String, ClassGen> classes) {
        for (Entry<String, ClassGen> c : classes.entrySet()) {
          for (Method m : c.getValue().getMethods()) {
            ConstantPoolGen cpg = c.getValue().getConstantPool();
            ClassGen cg = new ClassGen(c.getValue().getJavaClass());
            MethodGen gen = new MethodGen(m, c.getValue().getClassName(), cpg);
              InstructionList il = gen.getInstructionList();
              if (il == null) {
                 continue;
              }
View Full Code Here

Examples of org.apache.bcel.generic.ClassGen


  public SearchResult run(RSClient data, HashMap<String, ClassGen> classes) {
    RSClass nodeClass = data.getProperClass("Node");
    for(Entry<String, ClassGen> c : classes.entrySet()){
      ClassGen cg = new ClassGen(c.getValue().getJavaClass());
      ConstantPoolGen cpg = cg.getConstantPool();
      if(c.getValue().getSuperclassName().equals(nodeClass.className) && c.getValue().isFinal()){
        for(Method m : c.getValue().getMethods()){
          MethodSearcher mS = new MethodSearcher(m, cg, cpg);
          if(m.getName().equals("<init>") && mS.getArgCount() == 10 &&
              mS.getTypeCount("int") == 5 && mS.getTypeCount("java.lang.String")==2){
            MethodGen mg = new MethodGen(m, cg.getClassName(), cpg);
            RSClass menu = data.addClass("Menu", c.getValue().getClassName());
            int found = 0;
            InstructionSearcher iS = new InstructionSearcher(mg.getInstructionList(), cpg);
            Instruction i;
            FieldInstruction option;
View Full Code Here

Examples of org.apache.bcel.generic.ClassGen

  @Override
  public SearchResult run(RSClient data, HashMap<String, ClassGen> classes) {
    RSClass npc = data.getProperClass("NPC");
    for(Entry<String, ClassGen> c : classes.entrySet()){
      if(c.getValue().isFinal()){
        ClassGen cg = new ClassGen(c.getValue().getJavaClass());
        ConstantPoolGen cpg = cg.getConstantPool();
        for(Method m : c.getValue().getMethods()){
          MethodSearcher mS = new MethodSearcher(m, cg, cpg);
          if(m.getName().equals("<init>") && mS.getTypeCount(npc.className) == 1 &&
              mS.getArgCount() == 1){
            RSClass npcnode = data.addClass("NPCNode", c.getValue().getClassName());
            MethodGen mg = new MethodGen(m, cg.getClassName(), cpg);
            InstructionList il = mg.getInstructionList();
            InstructionSearcher iS = new InstructionSearcher(il, cpg);
            Instruction i = iS.nextPUTFIELD();
            npcnode.addField("GetNPC", ((PUTFIELD) i).getFieldName(cpg));
            return SearchResult.Success;
View Full Code Here

Examples of org.apache.bcel.generic.ClassGen

     * edu.umd.cs.findbugs.classfile.IAnalysisEngine#analyze(edu.umd.cs.findbugs
     * .classfile.IAnalysisCache, java.lang.Object)
     */
    @Override
    public ConstantPoolGen analyze(IAnalysisCache analysisCache, ClassDescriptor descriptor) throws CheckedAnalysisException {
        ClassGen classGen = new ClassGen(analysisCache.getClassAnalysis(JavaClass.class, descriptor));
        return classGen.getConstantPool();
    }
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.