Package org.apache.bcel.generic

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


    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

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

  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

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

 
  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


  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

  @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

     * 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

        }

  if(errors.size() == 0) {
    if(byte_code) {
      System.out.println("Pass 5: Generating byte code ...");
      ClassGen class_gen = new ClassGen(base_name, "java.lang.Object",
                file_name[j],
                ACC_PUBLIC | ACC_FINAL |
                ACC_SUPER, null);
      ConstantPoolGen cp = class_gen.getConstantPool();

      program.byte_code(class_gen, cp);
      JavaClass clazz = class_gen.getJavaClass();
      clazz.dump(base_name + ".class");
    }
    else {
      System.out.println("Pass 5: Generating Java code ...");
      PrintWriter out = new PrintWriter(new FileOutputStream(base_name + ".java"));
View Full Code Here

TOP

Related Classes of org.apache.bcel.generic.ClassGen

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.