Source:
<code><START> private IClasspathEntry addTestAttribute(IClasspathEntry entry) { <END> IClasspathAttribute[] classpathAttributes = entry.getExtraAttributes(); int length = classpathAttributes.length; System.arraycopy(classpathAttributes, 0, classpathAttributes = new IClasspathAttribute[length + 1], 0, length); classpathAttributes[length] = JavaCore.newClasspathAttribute(IClasspathEntryDescriptor.ATTRIBUTENAME_TEST, IClasspathEntryDescriptor.ATTRIBUTEVALUE_TRUE); switch(entry.getEntryKind()) { case IClasspathEntry.CPE_LIBRARY: return JavaCore.newLibraryEntry(entry.getPath(), entry.getSourceAttachmentPath(), entry.getSourceAttachmentRootPath(), entry.getAccessRules(), classpathAttributes, entry.isExported()); case IClasspathEntry.CPE_PROJECT: return JavaCore.newProjectEntry(entry.getPath(), entry.getAccessRules(), entry.combineAccessRules(), classpathAttributes, entry.isExported()); case IClasspathEntry.CPE_SOURCE: return JavaCore.newSourceEntry(entry.getPath(), entry.getInclusionPatterns(), entry.getExclusionPatterns(), entry.getOutputLocation(), classpathAttributes); case IClasspathEntry.CPE_VARIABLE: return JavaCore.newVariableEntry(entry.getPath(), entry.getSourceAttachmentPath(), entry.getSourceAttachmentRootPath(), entry.getAccessRules(), classpathAttributes, entry.isExported()); case IClasspathEntry.CPE_CONTAINER: return JavaCore.newContainerEntry(entry.getPath(), entry.getAccessRules(), classpathAttributes, entry.isExported()); } return entry; }</code><technical_language>check classpathentry attribute set true</technical_language>

Target:
private IClasspathEntry addTestAttribute(IClasspathEntry entry) { IClasspathAttribute[] classpathAttributes = entry.getExtraAttributes(); for(IClasspathAttribute classpathAttribute : classpathAttributes) { if(IClasspathEntryDescriptor.ATTRIBUTENAME_TEST.equals(classpathAttribute.getName())) { if(IClasspathEntryDescriptor.ATTRIBUTEVALUE_TRUE.equals(classpathAttribute.getValue())) { return entry; } classpathAttributes = Arrays.stream(classpathAttributes) .filter(e -> !e.getName().equals(IClasspathEntryDescriptor.ATTRIBUTENAME_TEST)) .toArray(IClasspathAttribute[]::new); break; } } int length = classpathAttributes.length; System.arraycopy(classpathAttributes, 0, classpathAttributes = new IClasspathAttribute[length + 1], 0, length); classpathAttributes[length] = JavaCore.newClasspathAttribute(IClasspathEntryDescriptor.ATTRIBUTENAME_TEST, IClasspathEntryDescriptor.ATTRIBUTEVALUE_TRUE); switch(entry.getEntryKind()) { case IClasspathEntry.CPE_LIBRARY: return JavaCore.newLibraryEntry(entry.getPath(), entry.getSourceAttachmentPath(), entry.getSourceAttachmentRootPath(), entry.getAccessRules(), classpathAttributes, entry.isExported()); case IClasspathEntry.CPE_PROJECT: return JavaCore.newProjectEntry(entry.getPath(), entry.getAccessRules(), entry.combineAccessRules(), classpathAttributes, entry.isExported()); case IClasspathEntry.CPE_SOURCE: return JavaCore.newSourceEntry(entry.getPath(), entry.getInclusionPatterns(), entry.getExclusionPatterns(), entry.getOutputLocation(), classpathAttributes); case IClasspathEntry.CPE_VARIABLE: return JavaCore.newVariableEntry(entry.getPath(), entry.getSourceAttachmentPath(), entry.getSourceAttachmentRootPath(), entry.getAccessRules(), classpathAttributes, entry.isExported()); case IClasspathEntry.CPE_CONTAINER: return JavaCore.newContainerEntry(entry.getPath(), entry.getAccessRules(), classpathAttributes, entry.isExported()); } log.error("unexpected entryKind " + entry.getEntryKind() + " for entry " + entry.getPath()); return entry; }