Package org.aspectj.apache.bcel.classfile

Examples of org.aspectj.apache.bcel.classfile.JavaClass


      // Bug 119657 ensure we use the unwoven aspect
      WeaverStateInfo wsi = type.getWeaverState();
      if (wsi != null && wsi.isReweavable()) {
        BcelObjectType classType = getClassType(type.getName());
        JavaClass wovenJavaClass = classType.getJavaClass();
        byte[] bytes = wsi.getUnwovenClassFileData(wovenJavaClass.getBytes());
        JavaClass unwovenJavaClass = Utility.makeJavaClass(wovenJavaClass.getFileName(), bytes);
        world.storeClass(unwovenJavaClass);
        classType.setJavaClass(unwovenJavaClass, true);
        // classType.setJavaClass(Utility.makeJavaClass(classType.
        // getJavaClass().getFileName(),
        // wsi.getUnwovenClassFileData(classType.getJavaClass().getBytes(
View Full Code Here


        }

        // FIXME ASC performance? of this alternative soln.
        int size = (int) entry.getSize();
        ClassParser parser = new ClassParser(new ByteArrayInputStream(FileUtil.readAsByteArray(inStream)), entry.getName());
        JavaClass jc = parser.parse();
        inStream.closeEntry();

        ResolvedType type = world.addSourceObjectType(jc, false).getResolvedTypeX();
        type.setBinaryPath(inFile.getAbsolutePath());
        if (type.isAspect()) {
View Full Code Here

   * @param directory directory which contained the class file
   * @return a ResolvedType if the classbytes represent an aspect, otherwise null
   */
  private ResolvedType isAspect(byte[] classbytes, String name, File dir) throws IOException {
    ClassParser parser = new ClassParser(new ByteArrayInputStream(classbytes), name);
    JavaClass jc = parser.parse();
    ResolvedType type = world.addSourceObjectType(jc, false).getResolvedTypeX();
    String typeName = type.getName().replace('.', File.separatorChar);
    int end = name.lastIndexOf(typeName + ".class");
    String binaryPath = null;
    // if end is -1 then something weird happened, the class file is not in
View Full Code Here

      // ().getFileName(), wsi.getUnwovenClassFileData()));
      // new: reweavable default with clever diff
      if (!world.isOverWeaving()) {
        byte[] bytes = wsi.getUnwovenClassFileData(classType.getJavaClass().getBytes());
        WeaverVersionInfo wvi = classType.getWeaverVersionAttribute();
        JavaClass newJavaClass = Utility.makeJavaClass(classType.getJavaClass().getFileName(), bytes);
        classType.setJavaClass(newJavaClass, true);
        classType.getResolvedTypeX().ensureConsistent();
      }
      // } else {
      // classType.resetState();
View Full Code Here

    perClauseMunger.forceMunge(cg, false);

    // TODO AV - unsafe cast
    // register the fresh new class into the world repository as it does not
    // exist on the classpath anywhere
    JavaClass jc = cg.getJavaClass((BcelWorld) world);
    ((BcelWorld) world).addSourceObjectType(jc, true);

    return jc.getBytes();
  }
View Full Code Here

  @Override
  protected ReferenceTypeDelegate resolveDelegate(ReferenceType ty) {
    String name = ty.getName();
    ensureAdvancedConfigurationProcessed();
    JavaClass jc = lookupJavaClass(classPath, name);
    if (jc == null) {
      // Anyone else to ask?
      if (typeDelegateResolvers != null) {
        for (TypeDelegateResolver tdr : typeDelegateResolvers) {
          ReferenceTypeDelegate delegate = tdr.getDelegate(ty);
View Full Code Here

  private JavaClass lookupJavaClass(ClassPathManager classPath, String name) {
    if (classPath == null) {
      try {
        ensureRepositorySetup();
        JavaClass jc = delegate.loadClass(name);
        if (trace.isTraceEnabled()) {
          trace.event("lookupJavaClass", this, new Object[] { name, jc });
        }
        return jc;
      } catch (ClassNotFoundException e) {
        if (trace.isTraceEnabled()) {
          trace.error("Unable to find class '" + name + "' in repository", e);
        }
        return null;
      }
    }

    ClassPathManager.ClassFile file = null;
    try {
      file = classPath.find(UnresolvedType.forName(name));
      if (file == null) {
        return null;
      }

      ClassParser parser = new ClassParser(file.getInputStream(), file.getPath());

      JavaClass jc = parser.parse();
      return jc;
    } catch (IOException ioe) {
      return null;
    } finally {
      if (file != null) {
View Full Code Here

    }

    ReferenceType nameTypeX = (ReferenceType) fromTheMap;

    if (nameTypeX == null) {
      JavaClass jc = Utility.makeJavaClass(classname, bytes);
      if (jc.isGeneric() && isInJava5Mode()) {
        nameTypeX = ReferenceType.fromTypeX(UnresolvedType.forRawTypeName(jc.getClassName()), this);
        ret = buildBcelDelegate(nameTypeX, jc, artificial, true);
        ReferenceType genericRefType = new ReferenceType(UnresolvedType.forGenericTypeSignature(signature,
            ret.getDeclaredGenericSignature()), this);
        nameTypeX.setDelegate(ret);
        genericRefType.setDelegate(ret);
View Full Code Here

    perClauseMunger.forceMunge(cg, false);

    // TODO AV - unsafe cast
    // register the fresh new class into the world repository as it does not
    // exist on the classpath anywhere
    JavaClass jc = cg.getJavaClass((BcelWorld) world);
    ((BcelWorld) world).addSourceObjectType(jc, true);

    bytes = jc.getBytes();
    return bytes;
  }
View Full Code Here

  private void workOutIfSynthetic() {
    if ((bitflags & KNOW_IF_SYNTHETIC) != 0) {
      return;
    }
    bitflags |= KNOW_IF_SYNTHETIC;
    JavaClass jc = bcelObjectType.getJavaClass();
    bitflags &= IS_SYNTHETIC_INVERSE; // unset the bit
    if (jc == null) {
      return; // what the hell has gone wrong?
    }
    if (jc.getMajor() < 49/* Java5 */) {
      // synthetic is an attribute
      String[] synthetics = getAttributeNames(false);
      if (synthetics != null) {
        for (int i = 0; i < synthetics.length; i++) {
          if (synthetics[i].equals("Synthetic")) {
View Full Code Here

TOP

Related Classes of org.aspectj.apache.bcel.classfile.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.