Package com.caucho.bytecode

Examples of com.caucho.bytecode.JavaClass


      if (_offset >= 0)
        return;

      switch (visitor.getOpcode()) {
      case CodeVisitor.INVOKESPECIAL:
        JavaClass javaClass = visitor.getJavaClass();
        ConstantPool cp = javaClass.getConstantPool();
        MethodRefConstant ref = cp.getMethodRef(visitor.getShortArg());

        // ejb/0l00
        // handler "super()" and "this()"
        if (ref.getName().equals("<init>")
      && (ref.getClassName().equals(javaClass.getThisClass())
    || ref.getClassName().equals(javaClass.getSuperClassName()))) {
          _offset = visitor.getOffset() + 3;
        }
        break;
      }
    }
View Full Code Here


      switch (visitor.getOpcode()) {
      case CodeVisitor.INVOKESPECIAL:
        int index = visitor.getShortArg();

  JavaClass jClass = visitor.getJavaClass();
        ConstantPool cp = jClass.getConstantPool();
        MethodRefConstant ref;
        ref = cp.getMethodRef(index);

  if (ref.getName().endsWith("__super")) {
    return;
  }
  else if (ref.getName().equals("<init>")
     && (! ref.getClassName().equals(jClass.getSuperClassName())
         || ! _method.getName().equals("<init>"))) {
    return;
  }
  else if (! ref.getName().equals("<init>")) {
    // private methods are called with invokespecial, but shouldn't
View Full Code Here

  parser.setClassLoader(_jClassLoader);
 
  ByteArrayInputStream is;
  is = new ByteArrayInputStream(buffer, 0, buffer.length);
     
  JavaClass jClass = parser.parse(is);

  return enhance(jClass);
      } catch (RuntimeException e) {
  throw e;
      } catch (Exception e) {
View Full Code Here

  protected void renameSubClass(String className,
                                Path targetPath,
                                Path extPath)
    throws Exception
  {
    JavaClass extClass = null;

    ByteCodeParser parser = new ByteCodeParser();

    parser = new ByteCodeParser();
    parser.setClassLoader(new JavaClassLoader());

    ReadStream is = extPath.openRead();
    try {
      extClass = parser.parse(is);
    } finally {
      if (is != null)
        is.close();
    }

    cleanExtConstantPool(className, extClass);

    WriteStream os = targetPath.openWrite();
    try {
      extClass.write(os);
    } finally {
      os.close();
    }
  }
View Full Code Here

                              Path targetPath,
                              Path sourcePath,
                              Path extPath)
    throws Exception
  {
    JavaClass baseClass = null;
    JavaClass extClass = null;

    ByteCodeParser parser = new ByteCodeParser();
    parser.setClassLoader(getJavaClassLoader());

    ReadStream is = sourcePath.openRead();
View Full Code Here

  protected void mergeClasses(String className,
                              Path targetPath,
                              Path extPath)
    throws Exception
  {
    JavaClass baseClass = null;
    JavaClass extClass = null;

    ByteCodeParser parser = new ByteCodeParser();
    parser.setClassLoader(getJavaClassLoader());

    ReadStream is = extPath.openRead();
    try {
      extClass = parser.parse(is);
    } finally {
      if (is != null)
        is.close();
    }

    cleanExtConstantPool(className, extClass);

    postEnhance(baseClass);

    WriteStream os = targetPath.openWrite();
    try {
      extClass.write(os);
    } finally {
      os.close();
    }
  }
View Full Code Here

      if (is == null)
  return null;
     
      try {
  JavaClass jClass = new ByteCodeParser().parse(is);

  Attribute attr = jClass.getAttribute("SourceDebugExtension");

  if (attr == null) {
    int p = cl.getName().indexOf('$');
   
    if (p > 0) {
View Full Code Here

      }

      log.fine("merging .smap for " + classPath.getTail());

      ByteCodeParser parser = new ByteCodeParser();
      JavaClass javaClass;

      ReadStream is = classPath.openRead();
      try {
        javaClass = parser.parse(is);
      } finally {
        is.close();
      }

      CharBuffer smap = new CharBuffer();

      is = smapPath.openRead();
      try {
        int ch;

        while ((ch = is.read()) >= 0) {
          smap.append((char) ch);
        }
      } finally {
        is.close();
      }

      SourceDebugExtensionAttribute attr;

      attr = new SourceDebugExtensionAttribute(smap.toString());

      javaClass.addAttribute(attr);

      WriteStream os = classPath.openWrite();
      try {
        javaClass.write(os);
      } finally {
        os.close();
      }
    } catch (Exception e) {
      log.log(Level.WARNING, e.toString(), e);
View Full Code Here

        ByteCodeParser parser = new ByteCodeParser();
        ReadStream is = source.openRead();
        WriteStream os = null;

        try {
          JavaClass cl = parser.parse(is);

          String cpOldName = sourceClass.replace('.', '/');
          String cpClassName = targetClass.replace('.', '/');

          int utf8Index = cl.getConstantPool().addUTF8(cpClassName).getIndex();
          cl.getConstantPool().getClass(cpOldName).setNameIndex(utf8Index);

          cl.setThisClass(cpClassName);

          // need to set descriptors, too

          // set private fields to protected
          ArrayList<JavaField> fields = cl.getFieldList();
          for (int i = 0; i < fields.size(); i++) {
            JavaField field = fields.get(i);

            int accessFlags = field.getAccessFlags();

            if ((accessFlags & ACC_PRIVATE) != 0) {
              accessFlags = (accessFlags & ~ ACC_PRIVATE) | ACC_PROTECTED;
              field.setAccessFlags(accessFlags);
            }
          }

          // set private methods to protected
          ArrayList<JavaMethod> methods = cl.getMethodList();
          for (int i = 0; i < methods.size(); i++) {
            JavaMethod method = methods.get(i);

            int accessFlags = method.getAccessFlags();

            if ((accessFlags & ACC_PRIVATE) != 0) {
              accessFlags = (accessFlags & ~ ACC_PRIVATE) | ACC_PROTECTED;
              method.setAccessFlags(accessFlags);
            }
          }

          for (int i = 0; i < _enhancerList.size(); i++) {
            _enhancerList.get(i).preEnhance(cl);
          }

          target.getParent().mkdirs();

          os = target.openWrite();

          cl.write(os);
        } finally {
          if (is != null)
            is.close();

          if (os != null)
View Full Code Here

        ByteCodeParser parser = new ByteCodeParser();
        ReadStream is = source.openRead();
        WriteStream os = null;

        try {
          JavaClass cl = parser.parse(is);

          String cpOldName = sourceClass.replace('.', '/');
          String cpClassName = targetClass.replace('.', '/');

          int utf8Index = cl.getConstantPool().addUTF8(cpClassName).getIndex();
          cl.getConstantPool().getClass(cpOldName).setNameIndex(utf8Index);

          cl.setThisClass(cpClassName);

          // need to set descriptors, too

          // set private fields to protected
          ArrayList<JavaField> fields = cl.getFieldList();
          for (int i = 0; i < fields.size(); i++) {
            JavaField field = fields.get(i);

            int accessFlags = field.getAccessFlags();

            if ((accessFlags & ACC_PRIVATE) != 0) {
              accessFlags = (accessFlags & ~ ACC_PRIVATE) | ACC_PROTECTED;
              field.setAccessFlags(accessFlags);
            }
          }

          // set private methods to protected
          ArrayList<JavaMethod> methods = cl.getMethodList();
          for (int i = 0; i < methods.size(); i++) {
            JavaMethod method = methods.get(i);

            int accessFlags = method.getAccessFlags();

            if ((accessFlags & ACC_PRIVATE) != 0) {
              accessFlags = (accessFlags & ~ ACC_PRIVATE) | ACC_PROTECTED;
              method.setAccessFlags(accessFlags);
            }
          }

          for (int i = 0; i < _enhancerList.size(); i++) {
            _enhancerList.get(i).preEnhance(cl);
          }

          target.getParent().mkdirs();

          os = target.openWrite();

          cl.write(os);
        } finally {
          if (is != null)
            is.close();

          if (os != null)
View Full Code Here

TOP

Related Classes of com.caucho.bytecode.JavaClass

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.