Package net.sf.cglib.asm

Examples of net.sf.cglib.asm.ClassReader


   * @param nbtCompoundClass - the compound clas.
   * @throws IOException If we cannot find these methods.
   */
  private void findMethodsUsingASM(final Class<?> tileEntityClass) throws IOException {
    final Class<?> nbtCompoundClass = MinecraftReflection.getNBTCompoundClass();
    final ClassReader reader = new ClassReader(tileEntityClass.getCanonicalName());
   
    final String tagCompoundName = getJarName(MinecraftReflection.getNBTCompoundClass());
    final String expectedDesc = "(L" + tagCompoundName + ";)V";
   
    reader.accept(new EmptyClassVisitor() {
      @Override
      public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
        final String methodName = name;
       
        // Detect read/write calls to NBTTagCompound
View Full Code Here


   * @param method - the method to analyse.
   * @return The method calls.
   * @throws IOException Cannot access the parent class.
   */
  public List<AsmMethod> getMethodCalls(Class<?> clazz, Method method) throws IOException {
    final ClassReader reader = new ClassReader(clazz.getCanonicalName());
    final List<AsmMethod> output = Lists.newArrayList();
   
    // The method we are looking for
    final String methodName = method.getName();
    final String methodDescription = Type.getMethodDescriptor(method);
   
    reader.accept(new EmptyClassVisitor() {
      @Override
      public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
        // Check method
        if (methodName.equals(name) && methodDescription.equals(desc)) {
          return new EmptyMethodVisitor() {
View Full Code Here

      final Class<?> packetUpdateAttributes = PacketRegistry.getPacketClassFromType(PacketType.Play.Server.UPDATE_ATTRIBUTES, true);
      final String packetSignature = packetUpdateAttributes.getCanonicalName().replace('.', '/');
     
      // HACK - class is found by inspecting code
      try {
        ClassReader reader = new ClassReader(packetUpdateAttributes.getCanonicalName());
       
        reader.accept(new EmptyClassVisitor() {
          @Override
          public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
            // The read method
            if (desc.startsWith("(Ljava/io/DataInput")) {
              return new EmptyMethodVisitor() {
View Full Code Here

/*     */
/*  92 */             if (DebuggingClassWriter.traceEnabled) {
/*  93 */               file = new File(new File(DebuggingClassWriter.debugLocation), dirs + ".asm");
/*  94 */               out = new BufferedOutputStream(new FileOutputStream(file));
/*     */               try {
/*  96 */                 ClassReader cr = new ClassReader(b);
/*  97 */                 PrintWriter pw = new PrintWriter(new OutputStreamWriter(out));
/*  98 */                 TraceClassVisitor tcv = new TraceClassVisitor(null, pw);
/*  99 */                 cr.accept(tcv, false);
/* 100 */                 pw.flush();
/*     */               } finally {
/* 102 */                 out.close();
/*     */               }
/*     */             }
View Full Code Here

/*  49 */             v = new AsmClassLoaderPreProcessor.PreProcessingVisitor(v, access, desc);
/*     */           }
/*  51 */           return v;
/*     */         }
/*     */       };
/*  54 */       new ClassReader(b).accept(w, false);
/*  55 */       return w.toByteArray();
/*     */     } catch (Exception e) {
/*  57 */       System.err.println("failed to patch ClassLoader:");
/*  58 */       e.printStackTrace();
/*  59 */     }return b;
View Full Code Here

/*  73 */         throw new ClassNotFoundException(name);
/*     */       }
/*     */
/*     */       try
/*     */       {
/*  78 */         r = new ClassReader(is);
/*     */       }
/*     */       finally
/*     */       {
/*     */         ClassReader r;
/*  82 */         is.close();
/*     */       }
/*     */     }
/*     */     catch (IOException e)
/*     */     {
/*     */       ClassReader r;
/*  86 */       throw new ClassNotFoundException(name + ":" + e.getMessage());
/*     */     }
/*     */     try
/*     */     {
/*     */       ClassReader r;
/*  90 */       ClassWriter w = new DebuggingClassWriter(true);
/*  91 */       getGenerator(r).generateClass(w);
/*  92 */       byte[] b = w.toByteArray();
/*  93 */       Class c = super.defineClass(name, b, 0, b.length, DOMAIN);
/*  94 */       postProcess(c);
View Full Code Here

/*     */               catch (ClassNotFoundException e)
/*     */               {
/*     */               }
/* 215 */             if (gen == null) {
/* 216 */               b = this.strategy.generate(this);
/* 217 */               String className = ClassNameReader.getClassName(new ClassReader(b));
/* 218 */               getClassNameCache(loader).add(className);
/* 219 */               gen = ReflectUtils.defineClass(className, b, loader);
/*     */             }
/*     */
/* 222 */             if (this.useCache) {
View Full Code Here

/*     */   }
/*     */
/*     */   private void processClassFile(File file)
/*     */     throws Exception, FileNotFoundException, IOException, MalformedURLException
/*     */   {
/*  86 */     ClassReader reader = getClassReader(file);
/*  87 */     String[] name = ClassNameReader.getClassInfo(reader);
/*  88 */     ClassWriter w = new DebuggingClassWriter(true);
/*  89 */     ClassTransformer t = getClassTransformer(name);
/*  90 */     if (t != null)
/*     */     {
View Full Code Here

/*     */   }
/*     */
/*     */   private static ClassReader getClassReader(File file) throws Exception {
/* 114 */     InputStream in = new BufferedInputStream(new FileInputStream(file));
/*     */     try {
/* 116 */       ClassReader r = new ClassReader(in);
/* 117 */       ClassReader localClassReader1 = r;
/*     */       return localClassReader1; } finally { in.close(); } throw localObject;
/*     */   }
View Full Code Here

/*     */   }
/*     */
/*     */   private byte[] process(byte[] bytes)
/*     */     throws Exception
/*     */   {
/* 224 */     ClassReader reader = new ClassReader(new ByteArrayInputStream(bytes));
/* 225 */     String[] name = ClassNameReader.getClassInfo(reader);
/* 226 */     ClassWriter w = new DebuggingClassWriter(true);
/* 227 */     ClassTransformer t = getClassTransformer(name);
/* 228 */     if (t != null) {
/* 229 */       if (this.verbose) {
/* 230 */         log("processing " + name[0]);
/*     */       }
/* 232 */       new TransformingClassGenerator(new ClassReaderGenerator(new ClassReader(new ByteArrayInputStream(bytes)), attributes(), skipDebug()), t).generateClass(w);
/*     */
/* 235 */       ByteArrayOutputStream out = new ByteArrayOutputStream();
/* 236 */       out.write(w.toByteArray());
/* 237 */       return out.toByteArray();
/*     */     }
View Full Code Here

TOP

Related Classes of net.sf.cglib.asm.ClassReader

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.