Package org.aspectj.apache.bcel.classfile

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


   *
   * @return class object for given fully qualified class name, or null if the class could not be found or parsed correctly
   */
  public static JavaClass lookupClass(String class_name) {
    try {
      JavaClass clazz = getRepository().findClass(class_name);

      if (clazz != null) {
        return clazz;
      }

View Full Code Here


   * Add clazz to repository if there isn't an equally named class already in there.
   *
   * @return old entry in repository
   */
  public static JavaClass addClass(JavaClass clazz) {
    JavaClass old = getRepository().findClass(clazz.getClassName());
    getRepository().storeClass(clazz);
    return old;
  }
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

  @Override
  protected ReferenceTypeDelegate resolveDelegate(ReferenceType ty) {
    String name = ty.getName();
    ensureAdvancedConfigurationProcessed();
    JavaClass jc = lookupJavaClass(classPath, name);
    if (jc == null) {
      return null;
    } else {
      return buildBcelDelegate(ty, jc, false, false);
    }
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

  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

    if (!(onMember instanceof AccessibleObject)) return Collections.EMPTY_SET;
    // here we really want both the runtime visible AND the class visible 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.Annotation[] anns = new org.aspectj.apache.bcel.classfile.annotation.Annotation[0];
      if (onMember instanceof Method) {
        org.aspectj.apache.bcel.classfile.Method bcelMethod = jc.getMethod((Method)onMember);
        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();
      if (anns == null) anns = new org.aspectj.apache.bcel.classfile.annotation.Annotation[0];
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.