Package org.aspectj.apache.bcel.classfile

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


  @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

      // 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

    // annotations
    // so we bail out to Bcel and then chuck away the JavaClass so that we
    // don't hog
    // memory.
    try {
      JavaClass jc = bcelRepository.loadClass(onMember.getDeclaringClass());
      org.aspectj.apache.bcel.classfile.annotation.AnnotationGen[] anns = new org.aspectj.apache.bcel.classfile.annotation.AnnotationGen[0];
      if (onMember instanceof Method) {
        org.aspectj.apache.bcel.classfile.Method bcelMethod = jc.getMethod((Method) onMember);
        if (bcelMethod == null) {
          // pr220430
          // System.err.println(
          // "Unexpected problem in Java15AnnotationFinder: cannot retrieve annotations on method '"
          // +
          // onMember.getName()+"' in class '"+jc.getClassName()+"'");
        } else {
          anns = bcelMethod.getAnnotations();
        }
      } else if (onMember instanceof Constructor) {
        org.aspectj.apache.bcel.classfile.Method bcelCons = jc.getMethod((Constructor) onMember);
        anns = bcelCons.getAnnotations();
      } else if (onMember instanceof Field) {
        org.aspectj.apache.bcel.classfile.Field bcelField = jc.getField((Field) onMember);
        anns = bcelField.getAnnotations();
      }
      // the answer is cached and we don't want to hold on to memory
      bcelRepository.clear();
      // OPTIMIZE make constant 0 size array for sharing
View Full Code Here

    return null;
  }

  public String getAnnotationDefaultValue(Member onMember) {
    try {
      JavaClass jc = bcelRepository.loadClass(onMember.getDeclaringClass());
      if (onMember instanceof Method) {
        org.aspectj.apache.bcel.classfile.Method bcelMethod = jc.getMethod((Method) onMember);

        if (bcelMethod == null) {
          // pr220430
          // System.err.println(
          // "Unexpected problem in Java15AnnotationFinder: cannot retrieve annotations on method '"
View Full Code Here

    // annotations
    // so we bail out to Bcel and then chuck away the JavaClass so that we
    // don't hog
    // memory.
    try {
      JavaClass jc = bcelRepository.loadClass(onMember.getDeclaringClass());
      org.aspectj.apache.bcel.classfile.annotation.AnnotationGen[] anns = new org.aspectj.apache.bcel.classfile.annotation.AnnotationGen[0];
      if (onMember instanceof Method) {
        org.aspectj.apache.bcel.classfile.Method bcelMethod = jc.getMethod((Method) onMember);
        if (bcelMethod == null) {
          // fallback on reflection - see pr220430
          // System.err.println(
          // "Unexpected problem in Java15AnnotationFinder: cannot retrieve annotations on method '"
          // +
          // onMember.getName()+"' in class '"+jc.getClassName()+"'");
        } else {
          anns = bcelMethod.getAnnotations();
        }
      } else if (onMember instanceof Constructor) {
        org.aspectj.apache.bcel.classfile.Method bcelCons = jc.getMethod((Constructor) onMember);
        anns = bcelCons.getAnnotations();
      } else if (onMember instanceof Field) {
        org.aspectj.apache.bcel.classfile.Field bcelField = jc.getField((Field) onMember);
        anns = bcelField.getAnnotations();
      }
      // the answer is cached and we don't want to hold on to memory
      bcelRepository.clear();
      // OPTIMIZE make this a constant 0 size array
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.