Package net.sf.rej.java

Examples of net.sf.rej.java.ClassFile


    try {
      ClassIndex ci = SystemFacade.getInstance().getClassIndex();
      ClassLocator cl = ci.getLocator(className);

      if (cl != null && cl.getFileSet().equals(this.openProject.getFileSet())) {
        ClassFile cf = SystemFacade.getInstance().getClassFile(cl);
        Link link = new Link();
        link.setText("Class definition : " + cf.getFullClassName());
        link.setAnchor(Link.ANCHOR_CLASS_DEF);
        link.setProject(this.openProject);
        link.setFile(cl.getFile());
        link.setTab(Tab.EDITOR);
        SystemFacade.getInstance().goTo(link);
View Full Code Here


            // file is already open and in the cache
            Object value = this.cache.get(filename);
            if(value instanceof ClassFile) {
                return (ClassFile)value;
            } else {
                ClassFile cf = (ClassFile)((SoftReference)value).get();
                if(cf != null) {
                    return cf;
                } // otherwise just load it from the i/o again
            }
        }

        byte[] data = this.fileset.getData(filename);
        try {
            ClassFile cf = Disassembler.readClass(data);
            this.cache.put(filename, new SoftReference<ClassFile>(cf));
            return cf;
        } catch (Exception e) {
            throw new ClassParsingException("Error parsing class file " + this.file + " : " + e.getMessage(), e);
        }
View Full Code Here

            fdr.getClassFile().getPool(), fdr.getField(), name,
            desc, af);
      }
    } else if (o instanceof ClassDefRow) {
      ClassDefRow cdr = (ClassDefRow) o;
      ClassFile cf = cdr.getClassFile();
      this.classEditor.invoke(cf.getFullClassName(), cf
          .getSuperClassName(), cf.getAccessFlags(), cf
          .getInterfaces());

      if (!this.classEditor.wasCancelled()) {
        String name = this.classEditor.getClassName();
        String superName = this.classEditor.getSuperClassname();
        AccessFlags flags = this.classEditor.getFlags();
        List<String> intfs = this.classEditor.getInterfaces();
        /* new list as user has modified it */
        List<Interface> remainingInterfaces = new ArrayList<Interface>();
        /* interfaces that remain untouched */
        List<Interface> old = cf.getInterfaces();
        /* interfaces before modification */
        List<String> oldNames = new ArrayList<String>();
        /* Names of interfaces before modification */

        for (int i = 0; i < old.size(); i++) {
View Full Code Here

  private void openStackFrame(IStackFrame sf) {
    ClassIndex ci = SystemFacade.getInstance().getClassIndex();
    ClassLocator cl = ci.getLocator(sf.location().declaringType().name());
    if (cl != null) {
      try {
        ClassFile cf = SystemFacade.getInstance().getClassFile(cl);
        IMethod bpMethod = sf.location().method();
        for (net.sf.rej.java.Method method : cf.getMethods()) {
          if (method.getName().equals(bpMethod.name()) && method.getDescriptor().getRawDesc().equals(bpMethod.signature())) {
            Integer pc = null;
            if (sf.location().codeIndex() != -1) {
              pc = (int)sf.location().codeIndex();
            }
           
            Event event = new Event(EventType.CLASS_OPEN);
            event.setClassFile(cf);
            event.setFile(cl.getFile());
            this.dispatcher.notifyObservers(event);
            setExecutionRow(method.getName(), method.getDescriptor(), pc);
            break;
          }
        }
      } catch(Exception ioe) {
        ioe.printStackTrace();
      }
    } else {
      ClassFactory factory = new ClassFactory();
      IReferenceType rt = sf.location().declaringType();
      String superClass = null;
      if (!"java.lang.Object".equals(rt.name())) {
        superClass = rt.getSuperClassName();
      }
      ClassFile cf = factory.createClass(rt.name(), superClass);
      ConstantPool cp = cf.getPool();
      FieldFactory fieldFactory = new FieldFactory();
      for (IField field : rt.visibleFields()) {
        AccessFlags flags = new AccessFlags(field.modifiers());
        Field fieldToAdd = fieldFactory.createField(cf, flags, cp.optionalAddUtf8(field.name()), cp.optionalAddUtf8(field.signature()));
        cf.add(fieldToAdd);
      }
     
      MethodFactory methodFactory = new MethodFactory();
      for (IMethod method : rt.visibleMethods()) {
        AccessFlags flags = new AccessFlags(method.modifiers());
        net.sf.rej.java.Method methodToAdd = methodFactory.createMethod(cf, flags, cp.optionalAddUtf8(method.name()), cp.optionalAddUtf8(method.signature()), cp.optionalAddUtf8("Code"), 0, 0, cp.optionalAddUtf8("Exceptions"), new ArrayList<ExceptionDescriptor>());
        cf.add(methodToAdd);
      }

      SystemFacade.getInstance().setStatus("Class definition pulled from VM: " + sf.location().declaringType().name());
      Event event = new Event(EventType.CLASS_OPEN);
      event.setClassFile(cf);
View Full Code Here

    this.batchMode = batchMode;
  }
 
  @Override
  public void postProcessFile(IterationContext ic) {
    ClassFile cf = ic.getCf();
    String oldClassName = this.oldClassNames.get(ic.getCf().getFullClassName());
    if (oldClassName != null) {
      String newFileName = getNewFileName(ic.getFilename(), oldClassName, cf.getFullClassName());
      Undoable u = new RenameFileAction(ic.getProject(), ic.getFilename(), newFileName, ic.getCf());
      if (this.batchMode) {
        FileSet fs = ic.getProject().getFileSet();
        fs.removeFile(ic.getFilename());
        fs.addFile(newFileName);
View Full Code Here

                this.selectedItem = ca;
                try {
                  byte[] dataA = this.filesetA.getData(ca.getFullNameA());
                  byte[] dataB = this.filesetB.getData(ca.getFullNameB());

                  ClassFile cfA = Disassembler.readClass(dataA);
                  ClassFile cfB = Disassembler.readClass(dataB);
                  this.comparePanel.setClassFiles(cfA, cfB);
                  this.tabbedPane.setSelectedComponent(this.comparePanel);
                } catch (Exception ex) {
                  SystemFacade.getInstance().handleException(ex);
                }
View Full Code Here

        @SuppressWarnings("unchecked")
        Wrapper<String> wrapper = (Wrapper)node.getUserObject();
        String file = wrapper.getContent();
        try {
          Event event = new Event(EventType.CLASS_OPEN);
          ClassFile cf = this.project.getClassFile(file);
          event.setClassFile(cf);
          event.setFile(file);
          this.dispatcher.notifyObservers(event);
        } catch(Exception ex) {
          SystemFacade.getInstance().handleException(ex);
View Full Code Here

TOP

Related Classes of net.sf.rej.java.ClassFile

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.