Example usage for org.eclipse.jdt.core IClasspathEntry CPE_SOURCE

List of usage examples for org.eclipse.jdt.core IClasspathEntry CPE_SOURCE

Introduction

In this page you can find the example usage for org.eclipse.jdt.core IClasspathEntry CPE_SOURCE.

Prototype

int CPE_SOURCE

To view the source code for org.eclipse.jdt.core IClasspathEntry CPE_SOURCE.

Click Source Link

Document

Entry kind constant describing a classpath entry identifying a folder containing package fragments with source code to be compiled.

Usage

From source file:org.eclipse.ajdt.internal.core.ajde.CoreOutputLocationManager.java

License:Open Source License

/**
 * initialize the source folder locations only
 *//* w w w. j a  v  a2  s.  c  o  m*/
private void initSourceFolders() {
    allSourceFolders = new TreeMap<String, String>(comparator);
    try {
        IClasspathEntry[] cpe = jProject.getRawClasspath();
        for (int i = 0; i < cpe.length; i++) {
            if (cpe[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) {
                IPath path = cpe[i].getPath();
                IPath rawPath;
                path = path.removeFirstSegments(1).makeRelative();
                if (path.segmentCount() > 0) {
                    IFolder folder = project.getFolder(path);
                    rawPath = folder.getLocation();
                } else {
                    rawPath = project.getLocation();
                }
                allSourceFolders.put(rawPath.toOSString(), path.toPortableString());
            }
        }
    } catch (JavaModelException e) {
    }
}

From source file:org.eclipse.ajdt.internal.core.ajde.CoreOutputLocationManager.java

License:Open Source License

/**
 * Calculate all the output locations//from w ww . java  2 s.  co m
 */
private void init() {
    outputIsRoot = false;
    String inpathOutFolderString = getInpathOutputFolder();
    boolean isUsingNonDefaultInpathOutfolder = inpathOutFolderString != null;

    try {
        IPath outputLocationPath = jProject.getOutputLocation();
        defaultOutput = workspacePathToFile(outputLocationPath);
        allOutputFolders.add(defaultOutput);

        fileSystemPathToIContainer.put(defaultOutput.getAbsolutePath(),
                project.getFullPath().equals(outputLocationPath) ? (IContainer) project
                        : (IContainer) workspaceRoot.getFolder(outputLocationPath));

        IClasspathEntry[] cpe = jProject.getRawClasspath();

        // store separate output folders in map
        for (int i = 0; i < cpe.length; i++) {
            if (cpe[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) {
                IPath output = cpe[i].getOutputLocation();
                if (output != null) {
                    IPath path = cpe[i].getPath();

                    String srcFolder = path.removeFirstSegments(1).toPortableString();
                    if (path.segmentCount() == 1) { // output folder is project
                        srcFolder = path.toPortableString();
                    }
                    File out = workspacePathToFile(output);
                    srcFolderToOutput.put(srcFolder, out);
                    if (!allOutputFolders.contains(out)) {
                        allOutputFolders.add(out);

                        fileSystemPathToIContainer.put(out.getAbsolutePath(), workspaceRoot.getFolder(output));
                    }
                    if (outputIsRoot) {
                        // bug 153682: if the project is the source folder
                        // then this output folder will always apply
                        defaultOutput = out;
                    }
                }
            }
        }

        // check to see if on inpath and need a special out folder for it.
        if (isUsingNonDefaultInpathOutfolder) {
            // first add the inpath out folder to the list of out folders
            IPath inpathOutFolderPath = new Path(inpathOutFolderString);
            IFolder inpathOutFolder = workspaceRoot.getFolder(inpathOutFolderPath);
            File out = inpathOutFolder.getLocation().toFile();
            fileSystemPathToIContainer.put(out.getAbsolutePath(), workspaceRoot.getFolder(inpathOutFolderPath));

            // now map everything coming from the in path to this out folder
            for (int i = 0; i < cpe.length; i++) {
                if (AspectJCorePreferences.isOnInpath(cpe[i])) {
                    // now must resolve the entry so that all jars contained in it 
                    // are mapped.
                    List<IClasspathEntry> containerEntries = AspectJCorePreferences.resolveClasspath(cpe[i],
                            project);
                    for (IClasspathEntry containerEntry : containerEntries) {
                        IPath path = containerEntry.getPath();
                        File f = workspacePathToFile(path);
                        if (f != null && f.exists()) {
                            // use full path
                            String srcFolder = new Path(f.getPath()).toPortableString();
                            srcFolderToOutput.put(srcFolder, out);
                        } else {
                            // outfolder does not exist
                            // probably because Project has been renamed
                            // and inpath output location has not been updated.
                            // this is handled with a message to the user
                        }
                    }
                }
            }
        }
    } catch (JavaModelException e) {
    }
}

From source file:org.eclipse.ajdt.internal.core.ajde.CoreOutputLocationManager.java

License:Open Source License

/**
 * @return true if there is more than one output directory being used by
 *         this project and false otherwise
 *//*from   w  ww  . j  a v  a2s  . c o  m*/
private boolean isUsingSeparateOutputFolders(IJavaProject jp) {
    if (getInpathOutputFolder() != null) {
        return true;
    }
    try {
        IClasspathEntry[] cpe = jp.getRawClasspath();
        for (int i = 0; i < cpe.length; i++) {
            if (cpe[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) {
                if (cpe[i].getOutputLocation() != null) {
                    return true;
                }
            }
        }
    } catch (JavaModelException e) {
    }
    return false;
}

From source file:org.eclipse.ajdt.internal.core.ajde.CoreOutputLocationManager.java

License:Open Source License

private void mapProject(IJavaProject jp) throws JavaModelException {
    IClasspathEntry[] cpes = jp.getRawClasspath();
    for (int i = 0; i < cpes.length; i++) {
        if (cpes[i].isExported() || cpes[i].getEntryKind() == IClasspathEntry.CPE_SOURCE || jp == jProject) {
            handleClassPathEntry(jp, cpes[i]);
        }//ww w.java2  s. c o m
    }
}

From source file:org.eclipse.ajdt.internal.core.ajde.CoreOutputLocationManager.java

License:Open Source License

private void handleClassPathEntry(IJavaProject jp, IClasspathEntry cpe) throws JavaModelException {
    switch (cpe.getEntryKind()) {
    case IClasspathEntry.CPE_CONTAINER:
        IClasspathContainer container = JavaCore.getClasspathContainer(cpe.getPath(), jp);
        if (container != null && container.getKind() != IClasspathContainer.K_DEFAULT_SYSTEM) {
            IClasspathEntry[] cpes = container.getClasspathEntries();
            for (int i = 0; i < cpes.length; i++) {
                handleClassPathEntry(jp, cpes[i]);
            }/*from  w w w . j a v  a2s.  c  o  m*/
        }
        break;
    case IClasspathEntry.CPE_LIBRARY:
        File libFile = pathToFile(cpe.getPath());
        if (libFile.isDirectory()) { // ignore jar files
            if (libFile != null && !binFolderToProject.containsKey(libFile)) {
                binFolderToProject.put(libFile, jp.getProject());
            }
        }
        break;
    case IClasspathEntry.CPE_PROJECT:
        IJavaProject jpClasspath = pathToProject(cpe.getPath());
        if (jpClasspath != null) {
            mapProject(jpClasspath);
        }
        break;

    case IClasspathEntry.CPE_SOURCE:
        File outFile = pathToFile(
                cpe.getOutputLocation() == null ? jp.getOutputLocation() : cpe.getOutputLocation());
        if (outFile != null && !binFolderToProject.containsKey(outFile)) {
            binFolderToProject.put(outFile, jp.getProject());
        }
        break;
    case IClasspathEntry.CPE_VARIABLE:
        IClasspathEntry cpeResolved = JavaCore.getResolvedClasspathEntry(cpe);
        if (cpeResolved != null) {
            handleClassPathEntry(jp, cpeResolved);
        }
        break;
    }
}

From source file:org.eclipse.ajdt.internal.core.builder.BuildClasspathResolver.java

License:Open Source License

private void computeClasspathLocations(IWorkspaceRoot root, JavaProject javaProject,
        SimpleLookupTable binaryLocationsPerProject) throws CoreException {

    /* Update cycle marker */
    IMarker cycleMarker = javaProject.getCycleMarker();
    if (cycleMarker != null) {
        int severity = JavaCore.ERROR.equals(javaProject.getOption(JavaCore.CORE_CIRCULAR_CLASSPATH, true))
                ? IMarker.SEVERITY_ERROR
                : IMarker.SEVERITY_WARNING;
        if (severity != ((Integer) cycleMarker.getAttribute(IMarker.SEVERITY)).intValue())
            cycleMarker.setAttribute(IMarker.SEVERITY, severity);
    }/*from   w  w w  . ja  v a  2  s . com*/

    IClasspathEntry[] classpathEntries = javaProject.getExpandedClasspath();
    ArrayList sLocations = new ArrayList(classpathEntries.length);
    ArrayList bLocations = new ArrayList(classpathEntries.length);
    nextEntry: for (int i = 0, l = classpathEntries.length; i < l; i++) {
        ClasspathEntry entry = (ClasspathEntry) classpathEntries[i];
        IPath path = entry.getPath();
        Object target = JavaModel.getTarget(path, true);
        if (target == null)
            continue nextEntry;

        switch (entry.getEntryKind()) {
        case IClasspathEntry.CPE_SOURCE:
            if (!(target instanceof IContainer))
                continue nextEntry;
            IPath outputPath = entry.getOutputLocation() != null ? entry.getOutputLocation()
                    : javaProject.getOutputLocation();
            IContainer outputFolder;
            if (outputPath.segmentCount() == 1) {
                outputFolder = javaProject.getProject();
            } else {
                outputFolder = root.getFolder(outputPath);
                // AspectJ Change Begin
                // This method can be executing on the wrong thread, where createFolder() will hang, so don't do it!
                // if (!outputFolder.exists())
                //    createFolder(outputFolder);
                // AspectJ Change End
            }
            sLocations.add(ClasspathLocation.forSourceFolder((IContainer) target, outputFolder,
                    entry.fullInclusionPatternChars(), entry.fullExclusionPatternChars()));
            continue nextEntry;

        case IClasspathEntry.CPE_PROJECT:
            if (!(target instanceof IProject))
                continue nextEntry;
            IProject prereqProject = (IProject) target;
            if (!JavaProject.hasJavaNature(prereqProject))
                continue nextEntry; // if project doesn't have java nature or is not accessible

            JavaProject prereqJavaProject = (JavaProject) JavaCore.create(prereqProject);
            IClasspathEntry[] prereqClasspathEntries = prereqJavaProject.getRawClasspath();
            ArrayList seen = new ArrayList();
            nextPrereqEntry: for (int j = 0, m = prereqClasspathEntries.length; j < m; j++) {
                IClasspathEntry prereqEntry = prereqClasspathEntries[j];
                if (prereqEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
                    Object prereqTarget = JavaModel.getTarget(prereqEntry.getPath(), true);
                    if (!(prereqTarget instanceof IContainer))
                        continue nextPrereqEntry;
                    IPath prereqOutputPath = prereqEntry.getOutputLocation() != null
                            ? prereqEntry.getOutputLocation()
                            : prereqJavaProject.getOutputLocation();
                    IContainer binaryFolder = prereqOutputPath.segmentCount() == 1 ? (IContainer) prereqProject
                            : (IContainer) root.getFolder(prereqOutputPath);
                    if (binaryFolder.exists() && !seen.contains(binaryFolder)) {
                        seen.add(binaryFolder);
                        ClasspathLocation bLocation = ClasspathLocation.forBinaryFolder(binaryFolder, true,
                                entry.getAccessRuleSet());
                        bLocations.add(bLocation);
                        if (binaryLocationsPerProject != null) { // normal builder mode
                            ClasspathLocation[] existingLocations = (ClasspathLocation[]) binaryLocationsPerProject
                                    .get(prereqProject);
                            if (existingLocations == null) {
                                existingLocations = new ClasspathLocation[] { bLocation };
                            } else {
                                int size = existingLocations.length;
                                System.arraycopy(existingLocations, 0,
                                        existingLocations = new ClasspathLocation[size + 1], 0, size);
                                existingLocations[size] = bLocation;
                            }
                            binaryLocationsPerProject.put(prereqProject, existingLocations);
                        }
                    }
                }
            }
            continue nextEntry;

        case IClasspathEntry.CPE_LIBRARY:
            if (target instanceof IResource) {
                IResource resource = (IResource) target;
                ClasspathLocation bLocation = null;
                if (resource instanceof IFile) {
                    if (!(org.eclipse.jdt.internal.compiler.util.Util
                            .isPotentialZipArchive(path.lastSegment())))
                        continue nextEntry;
                    AccessRuleSet accessRuleSet = JavaCore.IGNORE.equals(
                            javaProject.getOption(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE, true)) ? null
                                    : entry.getAccessRuleSet();
                    bLocation = ClasspathLocation.forLibrary((IFile) resource, accessRuleSet);
                } else if (resource instanceof IContainer) {
                    AccessRuleSet accessRuleSet = JavaCore.IGNORE.equals(
                            javaProject.getOption(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE, true)) ? null
                                    : entry.getAccessRuleSet();
                    bLocation = ClasspathLocation.forBinaryFolder((IContainer) target, false, accessRuleSet); // is library folder not output folder
                }
                bLocations.add(bLocation);
                if (binaryLocationsPerProject != null) { // normal builder mode
                    IProject p = resource.getProject(); // can be the project being built
                    ClasspathLocation[] existingLocations = (ClasspathLocation[]) binaryLocationsPerProject
                            .get(p);
                    if (existingLocations == null) {
                        existingLocations = new ClasspathLocation[] { bLocation };
                    } else {
                        int size = existingLocations.length;
                        System.arraycopy(existingLocations, 0,
                                existingLocations = new ClasspathLocation[size + 1], 0, size);
                        existingLocations[size] = bLocation;
                    }
                    binaryLocationsPerProject.put(p, existingLocations);
                }
            } else if (target instanceof File) {
                if (!(org.eclipse.jdt.internal.compiler.util.Util.isPotentialZipArchive(path.lastSegment())))
                    continue nextEntry;
                AccessRuleSet accessRuleSet = JavaCore.IGNORE
                        .equals(javaProject.getOption(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE, true)) ? null
                                : entry.getAccessRuleSet();
                bLocations.add(ClasspathLocation.forLibrary(path.toString(), accessRuleSet));
            }
            continue nextEntry;
        }
    }

    // now split the classpath locations... place the output folders ahead of the other .class file folders & jars
    ArrayList outputFolders = new ArrayList(1);
    this.sourceLocations = new ClasspathMultiDirectory[sLocations.size()];
    if (!sLocations.isEmpty()) {
        sLocations.toArray(this.sourceLocations);

        // collect the output folders, skipping duplicates
        next: for (int i = 0, l = sourceLocations.length; i < l; i++) {
            ClasspathMultiDirectory md = sourceLocations[i];
            IPath outputPath = md.binaryFolder.getFullPath();
            for (int j = 0; j < i; j++) { // compare against previously walked source folders
                if (outputPath.equals(sourceLocations[j].binaryFolder.getFullPath())) {
                    md.hasIndependentOutputFolder = sourceLocations[j].hasIndependentOutputFolder;
                    continue next;
                }
            }
            outputFolders.add(md);

            // also tag each source folder whose output folder is an independent folder & is not also a source folder
            for (int j = 0, m = sourceLocations.length; j < m; j++)
                if (outputPath.equals(sourceLocations[j].sourceFolder.getFullPath()))
                    continue next;
            md.hasIndependentOutputFolder = true;
        }
    }

    // combine the output folders with the binary folders & jars... place the output folders before other .class file folders & jars
    this.binaryLocations = new ClasspathLocation[outputFolders.size() + bLocations.size()];
    int index = 0;
    for (int i = 0, l = outputFolders.size(); i < l; i++)
        this.binaryLocations[index++] = (ClasspathLocation) outputFolders.get(i);
    for (int i = 0, l = bLocations.size(); i < l; i++)
        this.binaryLocations[index++] = (ClasspathLocation) bLocations.get(i);
}

From source file:org.eclipse.ajdt.internal.ui.ajde.UIMessageHandler.java

License:Open Source License

private IResource tryToFindResource(String fileName, IProject project) {
    IResource ret = null;/*from  w w w  .ja va 2  s  .com*/
    String toFind = fileName.replace('\\', '/');
    IJavaProject jProject = JavaCore.create(project);
    try {
        IClasspathEntry[] classpathEntries = jProject.getResolvedClasspath(false);
        for (int i = 0; i < classpathEntries.length; i++) {
            IClasspathEntry cpEntry = classpathEntries[i];
            if (cpEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
                IPath sourcePath = cpEntry.getPath();
                // remove the first segment because the findMember call
                // following always adds it back in under the covers (doh!) 
                // and we end up with two first segments otherwise!
                sourcePath = sourcePath.removeFirstSegments(1);

                IResource memberResource = project.findMember(sourcePath);
                if (memberResource != null) {
                    IResource[] srcContainer = new IResource[] { memberResource };
                    ret = findFile(srcContainer, toFind);
                }
            } else if (cpEntry.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
                IPath projPath = cpEntry.getPath();
                IResource projResource = AspectJPlugin.getWorkspace().getRoot().findMember(projPath);
                if (projResource != null) {
                    ret = findFile(new IResource[] { projResource }, toFind);
                }
            }
            if (ret != null) {
                break;
            }
        }
    } catch (JavaModelException jmEx) {
        AJDTErrorHandler.handleAJDTError(UIMessages.jmCoreException, jmEx);
    }

    if (ret == null)
        ret = project;
    return ret;
}

From source file:org.eclipse.ajdt.internal.ui.wizards.exports.AJJarFileExportOperation.java

License:Open Source License

private IContainer[] getOutputContainers(IJavaProject javaProject) throws CoreException {
    Set<IPath> outputPaths = new HashSet<IPath>();
    boolean includeDefaultOutputPath = false;
    IPackageFragmentRoot[] roots = javaProject.getPackageFragmentRoots();
    for (int i = 0; i < roots.length; i++) {
        if (roots[i] != null) {
            IClasspathEntry cpEntry = roots[i].getRawClasspathEntry();
            if (cpEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
                IPath location = cpEntry.getOutputLocation();
                if (location != null)
                    outputPaths.add(location);
                else
                    includeDefaultOutputPath = true;
            }/*from w w w  . ja v a2  s .  c o m*/
        }
    }

    if (includeDefaultOutputPath) {
        // Use default output location
        outputPaths.add(javaProject.getOutputLocation());
    }

    // Convert paths to containers
    Set<IContainer> outputContainers = new HashSet<IContainer>(outputPaths.size());
    Iterator<IPath> iter = outputPaths.iterator();
    while (iter.hasNext()) {
        IPath path = iter.next();
        if (javaProject.getProject().getFullPath().equals(path))
            outputContainers.add(javaProject.getProject());
        else {
            IFolder outputFolder = createFolderHandle(path);
            if (outputFolder == null || !outputFolder.isAccessible()) {
                String msg = JarPackagerMessages.JarFileExportOperation_outputContainerNotAccessible;
                addToStatus(new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(),
                        IJavaStatusConstants.INTERNAL_ERROR, msg, null)));
            } else
                outputContainers.add(outputFolder);
        }
    }
    return outputContainers.toArray(new IContainer[outputContainers.size()]);
}

From source file:org.eclipse.ajdt.internal.ui.wizards.exports.AJJarFileExportOperation.java

License:Open Source License

/**
 * Returns an iterator on a list with files that correspond to the
 * passed file and that are on the classpath of its project.
 *
 * @param   file         the file for which to find the corresponding classpath resources
 * @param   pathInJar      the path that the file has in the JAR (i.e. project and source folder segments removed)
 * @param   javaProject      the javaProject that contains the file
 * @param   pkgRoot         the package fragment root that contains the file
 * @return   the iterator over the corresponding classpath files for the given file
 *///from   ww w.  ja  v  a  2  s .c o  m
protected Iterator<IFile> filesOnClasspath(IFile file, IPath pathInJar, IJavaProject javaProject,
        IPackageFragmentRoot pkgRoot, IProgressMonitor progressMonitor) throws CoreException {
    // Allow JAR Package to provide its own strategy
    IFile[] classFiles = fJarPackage.findClassfilesFor(file);
    if (classFiles != null)
        return Arrays.asList(classFiles).iterator();

    if (!isJavaFile(file))
        return Collections.<IFile>emptyList().iterator();

    IPath outputPath = null;
    if (pkgRoot != null) {
        IClasspathEntry cpEntry = pkgRoot.getRawClasspathEntry();
        if (cpEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE)
            outputPath = cpEntry.getOutputLocation();
    }
    if (outputPath == null)
        // Use default output location
        outputPath = javaProject.getOutputLocation();

    IContainer outputContainer;
    if (javaProject.getProject().getFullPath().equals(outputPath))
        outputContainer = javaProject.getProject();
    else {
        outputContainer = createFolderHandle(outputPath);
        if (outputContainer == null || !outputContainer.isAccessible()) {
            String msg = JarPackagerMessages.JarFileExportOperation_outputContainerNotAccessible;
            throw new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(),
                    IJavaStatusConstants.INTERNAL_ERROR, msg, null));
        }
    }

    // Java CU - search files with .class ending
    boolean hasErrors = hasCompileErrors(file);
    boolean hasWarnings = hasCompileWarnings(file);
    boolean canBeExported = canBeExported(hasErrors, hasWarnings);
    if (!canBeExported)
        return Collections.<IFile>emptyList().iterator();
    reportPossibleCompileProblems(file, hasErrors, hasWarnings, canBeExported);
    IContainer classContainer = outputContainer;
    if (pathInJar.segmentCount() > 1)
        classContainer = outputContainer.getFolder(pathInJar.removeLastSegments(1));

    if (fExportedClassContainers.contains(classContainer))
        return Collections.<IFile>emptyList().iterator();

    if (fClassFilesMapContainer == null || !fClassFilesMapContainer.equals(classContainer)) {
        fJavaNameToClassFilesMap = buildJavaToClassMap(classContainer);
        if (fJavaNameToClassFilesMap == null) {
            // Could not fully build map. fallback is to export whole directory
            IPath location = classContainer.getLocation();
            String containerName = ""; //$NON-NLS-1$
            if (location != null)
                containerName = location.toFile().toString();
            String msg = Messages.format(
                    JarPackagerMessages.JarFileExportOperation_missingSourceFileAttributeExportedAll,
                    containerName);
            addInfo(msg, null);
            fExportedClassContainers.add(classContainer);
            return getClassesIn(classContainer);
        }
        fClassFilesMapContainer = classContainer;
    }
    ArrayList classFileList = (ArrayList) fJavaNameToClassFilesMap.get(file.getName());
    if (classFileList == null || classFileList.isEmpty()) {
        String msg = Messages.format(
                JarPackagerMessages.JarFileExportOperation_classFileOnClasspathNotAccessible,
                file.getFullPath());
        throw new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(),
                IJavaStatusConstants.INTERNAL_ERROR, msg, null));
    }
    return classFileList.iterator();
}

From source file:org.eclipse.ajdt.internal.ui.wizards.PathBlock.java

License:Open Source License

/**
 * Checks for duplicate entries on the inpath compared to the Java build
 * path//ww w  . j a v a  2  s .  co  m
 * 
 * This checks to make sure that duplicate entries are not being referred
 * to. For example, it is possible for the JUnit jar to be referred to
 * through a classpath variable as well as a classpath container. This
 * method checks for such duplicates
 * 
 * 1. if an inpath entry is on the build path, then remove it from checking
 * 2. resolve the remaining inpath entries 3. resolve the build path 4.
 * there should be no overlap
 */
private IJavaModelStatus checkForDuplicates(IJavaProject currJProject, IClasspathEntry[] entries) {
    try {
        Map<String, IClasspathEntry> allEntries = new HashMap<String, IClasspathEntry>(entries.length, 1.0f);
        for (int i = 0; i < entries.length; i++) {
            // ignore entries that are inside of a container
            if (getClasspathContainer(entries[i]) == null) {
                allEntries.put(entries[i].getPath().toPortableString(), entries[i]);
            }
        }

        IClasspathEntry[] rawProjectClasspath = currJProject.getRawClasspath();
        for (int i = 0; i < rawProjectClasspath.length; i++) {
            allEntries.remove(rawProjectClasspath[i].getPath().toPortableString());
        }

        IClasspathEntry[] resolvedProjectClasspath = currJProject.getResolvedClasspath(true);
        Map<String, IClasspathEntry> resolvedEntries = new HashMap<String, IClasspathEntry>();
        Iterator<IClasspathEntry> allEntriesIter = allEntries.values().iterator();
        while (allEntriesIter.hasNext()) {
            ClasspathEntry rawEntry = (ClasspathEntry) allEntriesIter.next();
            switch (rawEntry.entryKind) {
            case IClasspathEntry.CPE_SOURCE:
            case IClasspathEntry.CPE_LIBRARY:
            case IClasspathEntry.CPE_VARIABLE:
                IClasspathEntry resolvedEntry = JavaCore.getResolvedClasspathEntry(rawEntry);
                resolvedEntries.put(resolvedEntry.getPath().toPortableString(), resolvedEntry);
                break;
            case IClasspathEntry.CPE_CONTAINER:
                List containerEntries = AspectJCorePreferences.resolveClasspathContainer(rawEntry,
                        currJProject.getProject());

                for (Iterator containerIter = containerEntries.iterator(); containerIter.hasNext();) {
                    IClasspathEntry containerEntry = (IClasspathEntry) containerIter.next();
                    resolvedEntries.put(containerEntry.getPath().toPortableString(), containerEntry);
                }
                break;

            case IClasspathEntry.CPE_PROJECT:
                IProject thisProject = currJProject.getProject();
                IProject requiredProj = thisProject.getWorkspace().getRoot()
                        .getProject(rawEntry.getPath().makeRelative().toPortableString());
                if (!requiredProj.getName().equals(thisProject.getName()) && requiredProj.exists()) {
                    List containerEntries2 = AspectJCorePreferences.resolveDependentProjectClasspath(rawEntry,
                            requiredProj);
                    for (Iterator containerIter = containerEntries2.iterator(); containerIter.hasNext();) {
                        IClasspathEntry containerEntry = (IClasspathEntry) containerIter.next();
                        resolvedEntries.put(containerEntry.getPath().toPortableString(), containerEntry);
                    }

                }
                break;
            }
        }

        for (int i = 0; i < resolvedProjectClasspath.length; i++) {
            if (resolvedEntries.containsKey(resolvedProjectClasspath[i].getPath().toPortableString())) {
                // duplicate found.
                return new JavaModelStatus(IStatus.WARNING, IStatus.WARNING, currJProject,
                        currJProject.getPath(),
                        UIMessages.InPathBlock_DuplicateBuildEntry + resolvedProjectClasspath[i].getPath());
            }
        }

        return JavaModelStatus.VERIFIED_OK;
    } catch (JavaModelException e) {
        return new JavaModelStatus(e);
    }

}