Package org.eclipse.jdt.internal.compiler.classfmt

Examples of org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader


                try {

                    if (name.startsWith("play.") || name.startsWith("java.") || name.startsWith("javax.")) {
                        byte[] bytes = Play.classloader.getClassDefinition(name);
                        if (bytes != null) {
                            ClassFileReader classFileReader = new ClassFileReader(bytes, name.toCharArray(), true);
                            return new NameEnvironmentAnswer(classFileReader, null);
                        }
                        return null;
                    }

                    char[] fileName = name.toCharArray();
                    ApplicationClass applicationClass = applicationClasses.getApplicationClass(name);

                    // ApplicationClass exists
                    if (applicationClass != null) {

                        if (applicationClass.javaByteCode != null) {
                            ClassFileReader classFileReader = new ClassFileReader(applicationClass.javaByteCode, fileName, true);
                            return new NameEnvironmentAnswer(classFileReader, null);
                        }
                        // Cascade compilation
                        ICompilationUnit compilationUnit = new CompilationUnit(name);
                        return new NameEnvironmentAnswer(compilationUnit, null);
                    }

                    // So it's a standard class
                    byte[] bytes = Play.classloader.getClassDefinition(name);
                    if (bytes != null) {
                        ClassFileReader classFileReader = new ClassFileReader(bytes, fileName, true);
                        return new NameEnvironmentAnswer(classFileReader, null);
                    }

                    // So it does not exist
                    return null;
View Full Code Here


    }
    VariablesInfo installedVars = this.context.installedVars;
    if (installedVars != null) {
      ClassFile[] globalClassFiles = installedVars.classFiles;
      for (int i = 0; i < globalClassFiles.length; i++) {
        ClassFileReader binaryType = null;
        try {
          binaryType = new ClassFileReader(globalClassFiles[i].getBytes(), null);
        } catch (ClassFormatException e) {
          e.printStackTrace(); // Should never happen since we compiled this type
        }
        compiler.lookupEnvironment.cacheBinaryType(binaryType, null /*no access restriction*/);
      }
 
View Full Code Here

  VariablesInfo installedVars = this.context.installedVars;
  ClassFile[] classFiles = installedVars.classFiles;
  for (int i = 0; i < classFiles.length; i++) {
    ClassFile classFile = classFiles[i];
    if (CharOperation.equals(compoundTypeName, classFile.getCompoundName())) {
      ClassFileReader binary = null;
      try {
        binary = new ClassFileReader(classFile.getBytes(), null);
      } catch (ClassFormatException e) {
        e.printStackTrace()// Should never happen since we compiled this type
        return null;
      }
      return new NameEnvironmentAnswer(binary, null /*no access restriction*/);
 
View Full Code Here

}

public NameEnvironmentAnswer findClass(String binaryFileName, String qualifiedPackageName, String qualifiedBinaryFileName) {
  if (!doesFileExist(binaryFileName, qualifiedPackageName, qualifiedBinaryFileName)) return null; // most common case

  ClassFileReader reader = null;
  try {
    reader = Util.newClassFileReader(this.binaryFolder.getFile(new Path(qualifiedBinaryFileName)));
  } catch (CoreException e) {
    return null;
  } catch (ClassFormatException e) {
View Full Code Here

public NameEnvironmentAnswer findClass(char[] typeName, String qualifiedPackageName, String qualifiedBinaryFileName, boolean asBinaryOnly) {
  if (!isPackage(qualifiedPackageName))
    return null; // most common case

  try {
    ClassFileReader reader = ClassFileReader.read(this.zipFile, qualifiedBinaryFileName);
    if (reader != null)
      return new NameEnvironmentAnswer(reader, fetchAccessRestriction(qualifiedBinaryFileName));
  } catch(ClassFormatException e) {
    // treat as if class file is missing
  } catch (IOException e) {
View Full Code Here

          fullSourcePath, this.encoding, this.destinationPath),
          fetchAccessRestriction(qualifiedBinaryFileName));
  }
  if (binaryExists) {
    try {
      ClassFileReader reader = ClassFileReader.read(this.path + qualifiedBinaryFileName);
      // https://bugs.eclipse.org/bugs/show_bug.cgi?id=321115, package names are to be treated case sensitive.
      String typeSearched = qualifiedPackageName.length() > 0 ?
          qualifiedPackageName.replace(File.separatorChar, '/') + "/" + fileName //$NON-NLS-1$
          : fileName;
      if (!CharOperation.equals(reader.getName(), typeSearched.toCharArray())) {
        reader = null;
      }
      if (reader != null)
        return new NameEnvironmentAnswer(
            reader,
View Full Code Here

               
                final byte[] clazzBytes = pStore.read(pClazzName);
                if (clazzBytes != null) {
                    final char[] fileName = pClazzName.toCharArray();
                    try {
                        final ClassFileReader classFileReader = new ClassFileReader(clazzBytes, fileName, true);
                        return new NameEnvironmentAnswer(classFileReader, null);
                    } catch (final ClassFormatException e) {
                        throw new RuntimeException( "ClassFormatException in loading class '" + fileName + "' with JCI." );
                    }
                }
               
               
                final InputStream is = pClassLoader.getResourceAsStream(resourceName);
                if (is == null) {
                    return null;
                }

                final byte[] buffer = new byte[8192];
                final ByteArrayOutputStream baos = new ByteArrayOutputStream(buffer.length);
                int count;
                try {
                    while ((count = is.read(buffer, 0, buffer.length)) > 0) {
                        baos.write(buffer, 0, count);
                    }
                    baos.flush();
                    final char[] fileName = pClazzName.toCharArray();
                    final ClassFileReader classFileReader = new ClassFileReader(baos.toByteArray(), fileName, true);
                    return new NameEnvironmentAnswer(classFileReader, null);
                } catch ( final IOException e ) {
                    throw new RuntimeException( "could not read class",
                                                e );
                } catch ( final ClassFormatException e ) {
View Full Code Here

public NameEnvironmentAnswer findClass(String binaryFileName, String qualifiedPackageName, String qualifiedBinaryFileName) {
  if (!isPackage(qualifiedPackageName)) return null; // most common case

  try {
    ClassFileReader reader = ClassFileReader.read(this.zipFile, qualifiedBinaryFileName);
    if (reader != null) {
      if (this.accessRuleSet == null)
        return new NameEnvironmentAnswer(reader, null);
      String fileNameWithoutExtension = qualifiedBinaryFileName.substring(0, qualifiedBinaryFileName.length() - SuffixConstants.SUFFIX_CLASS.length);
      return new NameEnvironmentAnswer(reader, this.accessRuleSet.getViolatedRestriction(fileNameWithoutExtension.toCharArray()));
View Full Code Here

                                baos.write(buf, 0, count);
                            }
                            baos.flush();
                            classBytes = baos.toByteArray();
                            char[] fileName = className.toCharArray();
                            ClassFileReader classFileReader =
                                new ClassFileReader(classBytes, fileName,
                                                    true);
                            return
                                new NameEnvironmentAnswer(classFileReader, null);
                        }
                    } catch (IOException exc) {
View Full Code Here

                                baos.write(buf, 0, count);
                            }
                            baos.flush();
                            classBytes = baos.toByteArray();
                            char[] fileName = className.toCharArray();
                            ClassFileReader classFileReader =
                                new ClassFileReader(classBytes, fileName,
                                                    true);
                            return
                                new NameEnvironmentAnswer(classFileReader, null);
                        }
                    } catch (IOException exc) {
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader

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.