View | Details | Raw Unified | Return to bug 252431 | Differences between
and this patch

Collapse All | Expand All

(-)model/org/eclipse/jdt/core/IClasspathEntry.java (-1 / +58 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 418-423 Link Here
418
	 */
418
	 */
419
	IPath getSourceAttachmentRootPath();
419
	IPath getSourceAttachmentRootPath();
420
420
421
	
422
	/**
423
	 * Returns the library entry that is referencing this classpath entry. For CPE_LIBRARY, 
424
	 * this is the classpath entry that is representing the jar that mentions <code>this</code> 
425
	 * in the Class-Path clause of it's MANIFEST. For entry kinds other than CPE_LIBRARY, 
426
	 * this returns null.
427
	 * 
428
	 * @return the classpath entry that is referencing this entry.
429
	 * @since 3.6
430
	 */
431
	IClasspathEntry getReferencingEntry();
432
	
433
	/**
434
	 * Returns an array of classpath entries that are chained to <code>this</code>. For the entry
435
	 * kind CPE_LIBRARY, the method returns the libraries that are included in the Class-Path 
436
	 * clause of the MANIFEST file. For other entry kinds, this method returns an empty array. 
437
	 * If a chained library is already part of the raw classpath of the project, that will not be 
438
	 * included in the returned list.
439
	 * <p>
440
	 * The chained libraries attached to a particular classpath entry depends on the following 
441
	 * factors apart from the MANIFEST entries:
442
	 * <li> The order in which this entry appears in the classpath of a project - when a same 
443
	 * (chained) library is referenced in more than one library entry {@link #CPE_LIBRARY}, the 
444
	 * chained library is attached only to the first raw classpath entry and not to the latter 
445
	 * ones. For instance, if there are two library entries in the raw classpath and both include 
446
	 * the same set of jars in the MANIFEST, then the first entry will get all the chained jars 
447
	 * while the second gets none. </li> 
448
	 * <li>If a chained library is also directly part of the raw classpath, it does not get added 
449
	 * as chained library to any entry. </li>
450
	 * <li> {@link IClasspathEntry#excludeChainedJars()} - If this flag is turned on for this 
451
	 * classpath entry, then no chained libraries get added to <code>this</code>. Apart from this, 
452
	 * it could also affect the chained libraries of the other classpath entries in the project's 
453
	 * raw classpath.
454
	 * </p>
455
	 * <p>
456
	 * The chained libraries themselves will not have any further chained entries.
457
	 * </p>
458
	 * 
459
	 * @return the array of classpath entries that this entry makes references to.
460
	 * @since 3.6
461
	 */
462
	IClasspathEntry[] getChainedEntries();
463
	
464
	/**
465
	 * Returns whether the chained Jars should be included as part of the resolved build path.
466
	 * For entry kinds other than library {@link #CPE_LIBRARY}, this flag does not affect the 
467
	 * classpath in any way. Setting this flag off will detach all the chained entries from 
468
	 * <code>this</code> entry at once. However, this does not always guarantee that these 
469
	 * libraries will be removed from the resolved classpath. 
470
	 * <p>
471
	 * For more, refer to {@link IClasspathEntry#getChainedEntries()} </p> 
472
	 * 
473
	 * @return whether or not the chained jars should be excluded from this classpath entry.
474
	 * @since 3.6
475
	 */
476
	boolean excludeChainedJars();
477
	
421
	/**
478
	/**
422
	 * Returns whether this entry is exported to dependent projects.
479
	 * Returns whether this entry is exported to dependent projects.
423
	 * Always returns <code>false</code> for source entries (kind
480
	 * Always returns <code>false</code> for source entries (kind
(-)model/org/eclipse/jdt/core/IJavaProject.java (-2 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 611-617 Link Here
611
	 * The resulting resolved classpath is accurate for the given point in time.
611
	 * The resulting resolved classpath is accurate for the given point in time.
612
	 * If the project's raw classpath is later modified, or if classpath
612
	 * If the project's raw classpath is later modified, or if classpath
613
	 * variables are changed, the resolved classpath can become out of date.
613
	 * variables are changed, the resolved classpath can become out of date.
614
	 * Because of this, hanging on resolved classpath is not recommended.
614
	 * Because of this, hanging on resolved classpath is not recommended. 
615
	 * One such classpath attributes that can affect the resolved classpath is
616
	 * {@link IClasspathEntry#excludeChainedJars()}. This flag determines whether or
617
	 * not referenced (or chained) jars are included in the resolved classpath.
615
	 * </p>
618
	 * </p>
616
	 * <p>
619
	 * <p>
617
	 * Note that if the resolution creates duplicate entries 
620
	 * Note that if the resolution creates duplicate entries 
(-)model/org/eclipse/jdt/core/JavaCore.java (+79 lines)
Lines 4062-4067 Link Here
4062
			IClasspathAttribute[] extraAttributes,
4062
			IClasspathAttribute[] extraAttributes,
4063
			boolean isExported) {
4063
			boolean isExported) {
4064
4064
4065
		return newLibraryEntry(	
4066
						path, 
4067
						sourceAttachmentPath, 
4068
						sourceAttachmentRootPath, 
4069
						null, 
4070
						false, 
4071
						accessRules, 
4072
						extraAttributes, 
4073
						isExported);	
4074
	}
4075
4076
	/**
4077
	 * TODO (Jay) please complete
4078
	 * @since 3.6
4079
	 */
4080
	public static IClasspathEntry newLibraryEntry(
4081
			IPath path,
4082
			IPath sourceAttachmentPath,
4083
			IPath sourceAttachmentRootPath,
4084
			IClasspathEntry referencingEntry,
4085
			IAccessRule[] accessRules,
4086
			IClasspathAttribute[] extraAttributes,
4087
			boolean isExported) {
4088
4089
		return newLibraryEntry(
4090
						path, 
4091
						sourceAttachmentPath, 
4092
						sourceAttachmentRootPath, 
4093
						referencingEntry, 
4094
						ClasspathEntry.NO_ENTRIES,
4095
						false, 
4096
						accessRules, 
4097
						extraAttributes, 
4098
						isExported);
4099
	}
4100
	
4101
	/**
4102
	 * TODO (Jay) please complete
4103
	 * @since 3.6
4104
	 */
4105
	public static IClasspathEntry newLibraryEntry(
4106
			IPath path,
4107
			IPath sourceAttachmentPath,
4108
			IPath sourceAttachmentRootPath,
4109
			IClasspathEntry[] chainedEntries,
4110
			boolean excludeChained,
4111
			IAccessRule[] accessRules,
4112
			IClasspathAttribute[] extraAttributes,
4113
			boolean isExported) {
4114
		return newLibraryEntry(
4115
				path, 
4116
				sourceAttachmentPath, 
4117
				sourceAttachmentRootPath, 
4118
				null, 
4119
				chainedEntries,
4120
				excludeChained,
4121
				accessRules, 
4122
				extraAttributes, 
4123
				isExported);
4124
	}
4125
	
4126
	/**
4127
	 * TODO (Jay) please complete
4128
	 * @since 3.6
4129
	 */
4130
	public static IClasspathEntry newLibraryEntry(
4131
			IPath path,
4132
			IPath sourceAttachmentPath,
4133
			IPath sourceAttachmentRootPath,
4134
			IClasspathEntry referencingEntry,
4135
			IClasspathEntry[] chainedEntries,
4136
			boolean excludeNested,
4137
			IAccessRule[] accessRules,
4138
			IClasspathAttribute[] extraAttributes,
4139
			boolean isExported) {
4140
4065
		if (path == null) throw new ClasspathEntry.AssertionFailedException("Library path cannot be null"); //$NON-NLS-1$
4141
		if (path == null) throw new ClasspathEntry.AssertionFailedException("Library path cannot be null"); //$NON-NLS-1$
4066
		if (accessRules == null) {
4142
		if (accessRules == null) {
4067
			accessRules = ClasspathEntry.NO_ACCESS_RULES;
4143
			accessRules = ClasspathEntry.NO_ACCESS_RULES;
Lines 4089-4094 Link Here
4089
			sourceAttachmentPath,
4165
			sourceAttachmentPath,
4090
			sourceAttachmentRootPath,
4166
			sourceAttachmentRootPath,
4091
			null, // specific output folder
4167
			null, // specific output folder
4168
			referencingEntry,
4169
			chainedEntries,
4170
			excludeNested,
4092
			isExported,
4171
			isExported,
4093
			accessRules,
4172
			accessRules,
4094
			false, // no access rules to combine
4173
			false, // no access rules to combine
(-)model/org/eclipse/jdt/internal/core/ClasspathEntry.java (-74 / +222 lines)
Lines 92-102 Link Here
92
	public static final String TAG_COMBINE_ACCESS_RULES = "combineaccessrules"; //$NON-NLS-1$
92
	public static final String TAG_COMBINE_ACCESS_RULES = "combineaccessrules"; //$NON-NLS-1$
93
	public static final String TAG_ACCESS_RULES = "accessrules"; //$NON-NLS-1$
93
	public static final String TAG_ACCESS_RULES = "accessrules"; //$NON-NLS-1$
94
	public static final String TAG_ACCESS_RULE = "accessrule"; //$NON-NLS-1$
94
	public static final String TAG_ACCESS_RULE = "accessrule"; //$NON-NLS-1$
95
	public static final String TAG_REFERENCES = "references"; //$NON-NLS-1$
96
	public static final String TAG_REFERENCE = "reference"; //$NON-NLS-1$
95
	public static final String TAG_PATTERN = "pattern"; //$NON-NLS-1$
97
	public static final String TAG_PATTERN = "pattern"; //$NON-NLS-1$
96
	public static final String TAG_ACCESSIBLE = "accessible"; //$NON-NLS-1$
98
	public static final String TAG_ACCESSIBLE = "accessible"; //$NON-NLS-1$
97
	public static final String TAG_NON_ACCESSIBLE = "nonaccessible"; //$NON-NLS-1$
99
	public static final String TAG_NON_ACCESSIBLE = "nonaccessible"; //$NON-NLS-1$
98
	public static final String TAG_DISCOURAGED = "discouraged"; //$NON-NLS-1$
100
	public static final String TAG_DISCOURAGED = "discouraged"; //$NON-NLS-1$
99
	public static final String TAG_IGNORE_IF_BETTER = "ignoreifbetter"; //$NON-NLS-1$
101
	public static final String TAG_IGNORE_IF_BETTER = "ignoreifbetter"; //$NON-NLS-1$
102
	public static final String TAG_EXCLUDE_CHAINED = "excludechained"; //$NON-NLS-1$
100
103
101
	/**
104
	/**
102
	 * Describes the kind of classpath entry - one of
105
	 * Describes the kind of classpath entry - one of
Lines 141-147 Link Here
141
	private IPath[] exclusionPatterns;
144
	private IPath[] exclusionPatterns;
142
	private char[][] fullExclusionPatternChars;
145
	private char[][] fullExclusionPatternChars;
143
	private final static char[][] UNINIT_PATTERNS = new char[][] { "Non-initialized yet".toCharArray() }; //$NON-NLS-1$
146
	private final static char[][] UNINIT_PATTERNS = new char[][] { "Non-initialized yet".toCharArray() }; //$NON-NLS-1$
144
	private final static ClasspathEntry[] NO_ENTRIES = new ClasspathEntry[0];
147
	public final static ClasspathEntry[] NO_ENTRIES = new ClasspathEntry[0];
145
	private final static IPath[] NO_PATHS = new IPath[0];
148
	private final static IPath[] NO_PATHS = new IPath[0];
146
	private final static IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
149
	private final static IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
147
150
Lines 197-202 Link Here
197
	 * a non-<code>null</code> value.
200
	 * a non-<code>null</code> value.
198
	 */
201
	 */
199
	public IPath sourceAttachmentRootPath;
202
	public IPath sourceAttachmentRootPath;
203
	
204
	public IClasspathEntry[] chainedEntries;
205
206
	public IClasspathEntry referencingEntry;
207
	
208
	public boolean excludeChainedJars = false;
209
	
200
210
201
	/**
211
	/**
202
	 * Specific output location (for this source entry)
212
	 * Specific output location (for this source entry)
Lines 220-225 Link Here
220
	 */
230
	 */
221
	IClasspathAttribute[] extraAttributes;
231
	IClasspathAttribute[] extraAttributes;
222
232
233
	public ClasspathEntry(
234
			int contentKind,
235
			int entryKind,
236
			IPath path,
237
			IPath[] inclusionPatterns,
238
			IPath[] exclusionPatterns,
239
			IPath sourceAttachmentPath,
240
			IPath sourceAttachmentRootPath,
241
			IPath specificOutputLocation,
242
			boolean isExported,
243
			IAccessRule[] accessRules,
244
			boolean combineAccessRules,
245
			IClasspathAttribute[] extraAttributes) {
246
247
		this(	contentKind, 
248
				entryKind, 
249
				path, 
250
				inclusionPatterns, 
251
				exclusionPatterns, 
252
				sourceAttachmentPath, 
253
				sourceAttachmentRootPath, 
254
				specificOutputLocation,
255
				null,
256
				null,
257
				false,
258
				isExported,
259
				accessRules,
260
				combineAccessRules,
261
				extraAttributes);
262
	}
263
	
223
	/**
264
	/**
224
	 * Creates a class path entry of the specified kind with the given path.
265
	 * Creates a class path entry of the specified kind with the given path.
225
	 */
266
	 */
Lines 232-237 Link Here
232
		IPath sourceAttachmentPath,
273
		IPath sourceAttachmentPath,
233
		IPath sourceAttachmentRootPath,
274
		IPath sourceAttachmentRootPath,
234
		IPath specificOutputLocation,
275
		IPath specificOutputLocation,
276
		IClasspathEntry referencingEntry,
277
		IClasspathEntry[] chainedEntries,
278
		boolean excludeChainedJars,
235
		boolean isExported,
279
		boolean isExported,
236
		IAccessRule[] accessRules,
280
		IAccessRule[] accessRules,
237
		boolean combineAccessRules,
281
		boolean combineAccessRules,
Lines 242-248 Link Here
242
		this.path = path;
286
		this.path = path;
243
		this.inclusionPatterns = inclusionPatterns;
287
		this.inclusionPatterns = inclusionPatterns;
244
		this.exclusionPatterns = exclusionPatterns;
288
		this.exclusionPatterns = exclusionPatterns;
245
289
		this.referencingEntry = referencingEntry;
290
		this.excludeChainedJars = excludeChainedJars;
291
		this.chainedEntries = chainedEntries;
292
		
246
		int length;
293
		int length;
247
		if (accessRules != null && (length = accessRules.length) > 0) {
294
		if (accessRules != null && (length = accessRules.length) > 0) {
248
			AccessRule[] rules = new AccessRule[length];
295
			AccessRule[] rules = new AccessRule[length];
Lines 379-384 Link Here
379
			System.arraycopy(result, 0, result = new IAccessRule[index], 0, index);
426
			System.arraycopy(result, 0, result = new IAccessRule[index], 0, index);
380
		return result;
427
		return result;
381
	}
428
	}
429
	
430
	static IClasspathEntry[] decodeReferences(NodeList list, IClasspathEntry parent) {
431
		if (list == null) return null;
432
		int length = list.getLength();
433
		if (length == 0) return null;
434
		IClasspathEntry[] result = new IClasspathEntry[length];
435
		int index = 0;
436
		for (int i = 0; i < length; i++) {
437
			Node referencedEntry = list.item(i);
438
			if (referencedEntry.getNodeType() == Node.ELEMENT_NODE) {
439
				Element elementReference = (Element) referencedEntry;
440
				String path = elementReference.getAttribute(TAG_PATH);
441
				String sourceAttachment = elementReference.getAttribute(TAG_SOURCEPATH);
442
				String sourceRoot = elementReference.getAttribute(TAG_ROOTPATH);
443
				result[index++] = 
444
					new ClasspathEntry(
445
							parent.getContentKind(),
446
							parent.getEntryKind(),
447
							new Path(path),
448
							parent.getInclusionPatterns(),
449
							parent.getExclusionPatterns(),
450
							"".equals(sourceAttachment) ? null : new Path(sourceAttachment), //$NON-NLS-1$
451
							"".equals(sourceRoot) ? null : new Path(sourceRoot), //$NON-NLS-1$
452
							parent.getOutputLocation(),
453
							parent,
454
							new IClasspathEntry[0],
455
							parent.excludeChainedJars(),
456
							parent.isExported(),
457
							parent.getAccessRules(),
458
							parent.combineAccessRules(),
459
							parent.getExtraAttributes());
460
			}
461
		}
462
		if (index != length)
463
			System.arraycopy(result, 0, result = new ClasspathEntry[index], 0, index);
464
		return result;		
465
	}
382
466
383
	/**
467
	/**
384
	 * Decode some element tag containing a sequence of patterns into IPath[]
468
	 * Decode some element tag containing a sequence of patterns into IPath[]
Lines 494-529 Link Here
494
578
495
		parameters.put(TAG_KIND, ClasspathEntry.kindToString(this.entryKind));
579
		parameters.put(TAG_KIND, ClasspathEntry.kindToString(this.entryKind));
496
580
497
		IPath xmlPath = this.path;
581
		encodePathAttributes(projectPath, parameters);
498
		if (this.entryKind != IClasspathEntry.CPE_VARIABLE && this.entryKind != IClasspathEntry.CPE_CONTAINER) {
582
		
499
			// translate to project relative from absolute (unless a device path)
583
		if (this.entryKind == IClasspathEntry.CPE_LIBRARY) {
500
			if (xmlPath.isAbsolute()) {
584
			if (this.excludeChainedJars) {
501
				if (projectPath != null && projectPath.isPrefixOf(xmlPath)) {
585
				parameters.put(TAG_EXCLUDE_CHAINED, "true"); //$NON-NLS-1$
502
					if (xmlPath.segment(0).equals(projectPath.segment(0))) {
503
						xmlPath = xmlPath.removeFirstSegments(1);
504
						xmlPath = xmlPath.makeRelative();
505
					} else {
506
						xmlPath = xmlPath.makeAbsolute();
507
					}
508
				}
509
			}
586
			}
510
		}
587
		}
511
		parameters.put(TAG_PATH, String.valueOf(xmlPath));
512
513
		if (this.sourceAttachmentPath != null) {
514
			xmlPath = this.sourceAttachmentPath;
515
			// translate to project relative from absolute
516
			if (this.entryKind != IClasspathEntry.CPE_VARIABLE && projectPath != null && projectPath.isPrefixOf(xmlPath)) {
517
				if (xmlPath.segment(0).equals(projectPath.segment(0))) {
518
					xmlPath = xmlPath.removeFirstSegments(1);
519
					xmlPath = xmlPath.makeRelative();
520
				}
521
			}
522
			parameters.put(TAG_SOURCEPATH, String.valueOf(xmlPath));
523
		}
524
		if (this.sourceAttachmentRootPath != null) {
525
			parameters.put(TAG_ROOTPATH, String.valueOf(this.sourceAttachmentRootPath));
526
		}
527
		if (this.isExported) {
588
		if (this.isExported) {
528
			parameters.put(TAG_EXPORTED, "true");//$NON-NLS-1$
589
			parameters.put(TAG_EXPORTED, "true");//$NON-NLS-1$
529
		}
590
		}
Lines 553-564 Link Here
553
		boolean hasRestrictions = getAccessRuleSet() != null; // access rule set is null if no access rules
614
		boolean hasRestrictions = getAccessRuleSet() != null; // access rule set is null if no access rules
554
		ArrayList unknownChildren = unknownXmlElements != null ? unknownXmlElements.children : null;
615
		ArrayList unknownChildren = unknownXmlElements != null ? unknownXmlElements.children : null;
555
		boolean hasUnknownChildren = unknownChildren != null;
616
		boolean hasUnknownChildren = unknownChildren != null;
617
		boolean hasChainedEntries = getChainedEntries().length > 0 ? true : false;
618
		
619
		/* close tag if no extra attributes, no restriction, no unknown children and no chained classpath entries */
556
		writer.printTag(
620
		writer.printTag(
557
			TAG_CLASSPATHENTRY,
621
			TAG_CLASSPATHENTRY,
558
			parameters,
622
			parameters,
559
			indent,
623
			indent,
560
			newLine,
624
			newLine,
561
			!hasExtraAttributes && !hasRestrictions && !hasUnknownChildren/*close tag if no extra attributes, no restriction and no unknown children*/);
625
			!hasExtraAttributes && !hasRestrictions && !hasUnknownChildren && !hasChainedEntries);
562
626
563
		if (hasExtraAttributes)
627
		if (hasExtraAttributes)
564
			encodeExtraAttributes(writer, indent, newLine);
628
			encodeExtraAttributes(writer, indent, newLine);
Lines 566-578 Link Here
566
		if (hasRestrictions)
630
		if (hasRestrictions)
567
			encodeAccessRules(writer, indent, newLine);
631
			encodeAccessRules(writer, indent, newLine);
568
632
633
		if (this.getChainedEntries().length > 0) {
634
			encodeReferences(writer, projectPath, indent, newLine);
635
		}
569
		if (hasUnknownChildren)
636
		if (hasUnknownChildren)
570
			encodeUnknownChildren(writer, indent, newLine, unknownChildren);
637
			encodeUnknownChildren(writer, indent, newLine, unknownChildren);
571
638
572
		if (hasExtraAttributes || hasRestrictions || hasUnknownChildren)
639
		if (hasExtraAttributes || hasRestrictions || hasUnknownChildren || hasChainedEntries)
573
			writer.endTag(TAG_CLASSPATHENTRY, indent, true/*insert new line*/);
640
			writer.endTag(TAG_CLASSPATHENTRY, indent, true/*insert new line*/);
574
	}
641
	}
575
642
643
	private void encodePathAttributes(IPath projectPath, HashMap parameters) {
644
		IPath xmlPath = this.path;
645
		if (this.entryKind != IClasspathEntry.CPE_VARIABLE && this.entryKind != IClasspathEntry.CPE_CONTAINER) {
646
			// translate to project relative from absolute (unless a device path)
647
			if (xmlPath.isAbsolute()) {
648
				if (projectPath != null && projectPath.isPrefixOf(xmlPath)) {
649
					if (xmlPath.segment(0).equals(projectPath.segment(0))) {
650
						xmlPath = xmlPath.removeFirstSegments(1);
651
						xmlPath = xmlPath.makeRelative();
652
					} else {
653
						xmlPath = xmlPath.makeAbsolute();
654
					}
655
				}
656
			}
657
		}
658
		parameters.put(TAG_PATH, String.valueOf(xmlPath));
659
660
		if (this.sourceAttachmentPath != null) {
661
			xmlPath = this.sourceAttachmentPath;
662
			// translate to project relative from absolute
663
			if (this.entryKind != IClasspathEntry.CPE_VARIABLE && projectPath != null && projectPath.isPrefixOf(xmlPath)) {
664
				if (xmlPath.segment(0).equals(projectPath.segment(0))) {
665
					xmlPath = xmlPath.removeFirstSegments(1);
666
					xmlPath = xmlPath.makeRelative();
667
				}
668
			}
669
			parameters.put(TAG_SOURCEPATH, String.valueOf(xmlPath));
670
		}
671
		if (this.sourceAttachmentRootPath != null) {
672
			parameters.put(TAG_ROOTPATH, String.valueOf(this.sourceAttachmentRootPath));
673
		}
674
	}
675
576
	void encodeExtraAttributes(XMLWriter writer, boolean indent, boolean newLine) {
676
	void encodeExtraAttributes(XMLWriter writer, boolean indent, boolean newLine) {
577
		writer.startTag(TAG_ATTRIBUTES, indent);
677
		writer.startTag(TAG_ATTRIBUTES, indent);
578
		for (int i = 0; i < this.extraAttributes.length; i++) {
678
		for (int i = 0; i < this.extraAttributes.length; i++) {
Lines 617-622 Link Here
617
		writer.printTag(TAG_ACCESS_RULE, parameters, indent, newLine, true);
717
		writer.printTag(TAG_ACCESS_RULE, parameters, indent, newLine, true);
618
718
619
	}
719
	}
720
	
721
	void encodeReferences(XMLWriter writer, IPath projectPath, boolean indent, boolean newLine) {
722
		writer.startTag(TAG_REFERENCES, indent);
723
		IClasspathEntry[] references = getChainedEntries();
724
		for (int index = 0, length = references.length; index < length; index++) {
725
			HashMap parameters = new HashMap(3);
726
		
727
			((ClasspathEntry)references[index]).encodePathAttributes(projectPath, parameters);
728
			writer.printTag(TAG_REFERENCE, parameters, indent, newLine, true);
729
		}
730
		writer.endTag(TAG_REFERENCES, indent, true/*insert new line*/);		
731
	}
620
732
621
	private void encodeUnknownChildren(XMLWriter writer, boolean indent, boolean newLine, ArrayList unknownChildren) {
733
	private void encodeUnknownChildren(XMLWriter writer, boolean indent, boolean newLine, ArrayList unknownChildren) {
622
		for (int i = 0, length = unknownChildren.size(); i < length; i++) {
734
		for (int i = 0, length = unknownChildren.size(); i < length; i++) {
Lines 657-663 Link Here
657
769
658
		// exported flag (optional)
770
		// exported flag (optional)
659
		boolean isExported = removeAttribute(TAG_EXPORTED, attributes).equals("true"); //$NON-NLS-1$
771
		boolean isExported = removeAttribute(TAG_EXPORTED, attributes).equals("true"); //$NON-NLS-1$
660
772
		boolean excludeChained = removeAttribute(TAG_EXCLUDE_CHAINED, attributes).equals("true"); //$NON-NLS-1$
773
		
661
		// inclusion patterns (optional)
774
		// inclusion patterns (optional)
662
		IPath[] inclusionPatterns = decodePatterns(attributes, TAG_INCLUDING);
775
		IPath[] inclusionPatterns = decodePatterns(attributes, TAG_INCLUDING);
663
		if (inclusionPatterns == null) inclusionPatterns = INCLUDE_ALL;
776
		if (inclusionPatterns == null) inclusionPatterns = INCLUDE_ALL;
Lines 685-719 Link Here
685
		// custom output location
798
		// custom output location
686
		IPath outputLocation = element.hasAttribute(TAG_OUTPUT) ? projectPath.append(removeAttribute(TAG_OUTPUT, attributes)) : null;
799
		IPath outputLocation = element.hasAttribute(TAG_OUTPUT) ? projectPath.append(removeAttribute(TAG_OUTPUT, attributes)) : null;
687
800
688
		String[] unknownAttributes = null;
689
		ArrayList unknownChildren = null;
690
691
		if (unknownElements != null) {
692
			// unknown attributes
693
			int unknownAttributeLength = attributes.getLength();
694
			if (unknownAttributeLength != 0) {
695
				unknownAttributes = new String[unknownAttributeLength*2];
696
				for (int i = 0; i < unknownAttributeLength; i++) {
697
					Node attribute = attributes.item(i);
698
					unknownAttributes[i*2] = attribute.getNodeName();
699
					unknownAttributes[i*2 + 1] = attribute.getNodeValue();
700
				}
701
			}
702
703
			// unknown children
704
			for (int i = 0, length = foundChildren.length; i < length; i++) {
705
				if (!foundChildren[i]) {
706
					Node node = children.item(i);
707
					if (node.getNodeType() != Node.ELEMENT_NODE) continue;
708
					if (unknownChildren == null)
709
						unknownChildren = new ArrayList();
710
					StringBuffer buffer = new StringBuffer();
711
					decodeUnknownNode(node, buffer, project);
712
					unknownChildren.add(buffer.toString());
713
				}
714
			}
715
		}
716
717
		// recreate the CP entry
801
		// recreate the CP entry
718
		IClasspathEntry entry = null;
802
		IClasspathEntry entry = null;
719
		switch (kind) {
803
		switch (kind) {
Lines 738-746 Link Here
738
												path,
822
												path,
739
												sourceAttachmentPath,
823
												sourceAttachmentPath,
740
												sourceAttachmentRootPath,
824
												sourceAttachmentRootPath,
825
												null,
826
												excludeChained,
741
												accessRules,
827
												accessRules,
742
												extraAttributes,
828
												extraAttributes,
743
												isExported);
829
												isExported);
830
				NodeList referencesList = getChildAttributes(TAG_REFERENCES, children, foundChildren);
831
				IClasspathEntry[] references = decodeReferences(referencesList, entry);
832
				((ClasspathEntry)entry).setReferencedEntries(references);
744
				break;
833
				break;
745
			case IClasspathEntry.CPE_SOURCE :
834
			case IClasspathEntry.CPE_SOURCE :
746
				// must be an entry in this project or specify another project
835
				// must be an entry in this project or specify another project
Lines 807-812 Link Here
807
			default :
896
			default :
808
				throw new AssertionFailedException(Messages.bind(Messages.classpath_unknownKind, kindAttr));
897
				throw new AssertionFailedException(Messages.bind(Messages.classpath_unknownKind, kindAttr));
809
		}
898
		}
899
		
900
		String[] unknownAttributes = null;
901
		ArrayList unknownChildren = null;
902
903
		if (unknownElements != null) {
904
			// unknown attributes
905
			int unknownAttributeLength = attributes.getLength();
906
			if (unknownAttributeLength != 0) {
907
				unknownAttributes = new String[unknownAttributeLength*2];
908
				for (int i = 0; i < unknownAttributeLength; i++) {
909
					Node attribute = attributes.item(i);
910
					unknownAttributes[i*2] = attribute.getNodeName();
911
					unknownAttributes[i*2 + 1] = attribute.getNodeValue();
912
				}
913
			}
914
915
			// unknown children
916
			for (int i = 0, length = foundChildren.length; i < length; i++) {
917
				if (!foundChildren[i]) {
918
					Node node = children.item(i);
919
					if (node.getNodeType() != Node.ELEMENT_NODE) continue;
920
					if (unknownChildren == null)
921
						unknownChildren = new ArrayList();
922
					StringBuffer buffer = new StringBuffer();
923
					decodeUnknownNode(node, buffer, project);
924
					unknownChildren.add(buffer.toString());
925
				}
926
			}
927
		}
810
928
811
		if (unknownAttributes != null || unknownChildren != null) {
929
		if (unknownAttributes != null || unknownChildren != null) {
812
			UnknownXmlElements unknownXmlElements = new UnknownXmlElements();
930
			UnknownXmlElements unknownXmlElements = new UnknownXmlElements();
Lines 1019-1024 Link Here
1019
			if (this.entryKind != otherEntry.getEntryKind())
1137
			if (this.entryKind != otherEntry.getEntryKind())
1020
				return false;
1138
				return false;
1021
1139
1140
			if (this.excludeChainedJars != otherEntry.excludeChainedJars()) 
1141
				return false;
1142
			
1022
			if (this.isExported != otherEntry.isExported())
1143
			if (this.isExported != otherEntry.isExported())
1023
				return false;
1144
				return false;
1024
1145
Lines 1178-1183 Link Here
1178
		return this.sourceAttachmentRootPath;
1299
		return this.sourceAttachmentRootPath;
1179
	}
1300
	}
1180
1301
1302
1303
	public boolean excludeChainedJars() {
1304
		return this.excludeChainedJars;
1305
	}
1306
1307
	public IClasspathEntry getReferencingEntry() {
1308
		return this.referencingEntry;
1309
	}	
1310
	
1311
	public IClasspathEntry[] getChainedEntries() {
1312
		if (this.chainedEntries == null) {
1313
			return new IClasspathEntry[0];
1314
		}
1315
		return this.chainedEntries;
1316
	}
1317
	
1318
	public void setReferencedEntries(IClasspathEntry[] entries) {
1319
		this.chainedEntries = entries;
1320
	}
1321
	
1181
	/**
1322
	/**
1182
	 * Returns the hash code for this classpath entry
1323
	 * Returns the hash code for this classpath entry
1183
	 */
1324
	 */
Lines 1380-1385 Link Here
1380
							getSourceAttachmentPath(),
1521
							getSourceAttachmentPath(),
1381
							getSourceAttachmentRootPath(),
1522
							getSourceAttachmentRootPath(),
1382
							getOutputLocation(),
1523
							getOutputLocation(),
1524
							this.getReferencingEntry(),
1525
							this.getChainedEntries(),
1526
							this.excludeChainedJars(),
1383
							this.isExported,
1527
							this.isExported,
1384
							getAccessRules(),
1528
							getAccessRules(),
1385
							this.combineAccessRules,
1529
							this.combineAccessRules,
Lines 1397-1415 Link Here
1397
			return NO_ENTRIES;
1541
			return NO_ENTRIES;
1398
		ClasspathEntry[] result = new ClasspathEntry[length];
1542
		ClasspathEntry[] result = new ClasspathEntry[length];
1399
		for (int i = 0; i < length; i++) {
1543
		for (int i = 0; i < length; i++) {
1544
			//TODO: Consider a new constructor that doesn't require chainedEntries as param.
1400
			result[i] = new ClasspathEntry(
1545
			result[i] = new ClasspathEntry(
1401
									getContentKind(),
1546
					getContentKind(),
1402
									getEntryKind(),
1547
					getEntryKind(),
1403
									paths[i],
1548
					paths[i],
1404
									this.inclusionPatterns,
1549
					this.inclusionPatterns,
1405
									this.exclusionPatterns,
1550
					this.exclusionPatterns,
1406
									getSourceAttachmentPath(),
1551
					null,
1407
									getSourceAttachmentRootPath(),
1552
					null,
1408
									getOutputLocation(),
1553
					getOutputLocation(),
1409
									this.isExported,
1554
					this,
1410
									getAccessRules(),
1555
					null,
1411
									this.combineAccessRules,
1556
					false,
1412
									this.extraAttributes);
1557
					this.isExported,
1558
					getAccessRules(),
1559
					this.combineAccessRules,
1560
					this.extraAttributes);
1413
		}
1561
		}
1414
		return result;
1562
		return result;
1415
	}
1563
	}
(-)model/org/eclipse/jdt/internal/core/JavaProject.java (-16 / +93 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 18-23 Link Here
18
import java.util.Hashtable;
18
import java.util.Hashtable;
19
import java.util.Iterator;
19
import java.util.Iterator;
20
import java.util.LinkedHashSet;
20
import java.util.LinkedHashSet;
21
import java.util.List;
21
import java.util.Map;
22
import java.util.Map;
22
23
23
import javax.xml.parsers.DocumentBuilder;
24
import javax.xml.parsers.DocumentBuilder;
Lines 2539-2545 Link Here
2539
		JavaModelManager manager = JavaModelManager.getJavaModelManager();
2540
		JavaModelManager manager = JavaModelManager.getJavaModelManager();
2540
		ExternalFoldersManager externalFoldersManager = JavaModelManager.getExternalManager();
2541
		ExternalFoldersManager externalFoldersManager = JavaModelManager.getExternalManager();
2541
		ResolvedClasspath result = new ResolvedClasspath();
2542
		ResolvedClasspath result = new ResolvedClasspath();
2542
2543
		
2544
		Map oldChainedEntries = new HashMap();
2545
		if (resolveChainedLibraries) {
2546
			for (int index = 0; index < rawClasspath.length; index++) {
2547
				if (rawClasspath[index].getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
2548
					IClasspathEntry[] chainedEntries = ((ClasspathEntry)rawClasspath[index]).getChainedEntries();
2549
					for (int chainIndex = 0; chainIndex < chainedEntries.length; chainIndex++) {
2550
						oldChainedEntries.put(chainedEntries[chainIndex].getPath(), chainedEntries[chainIndex]);
2551
					}
2552
				}
2553
			}
2554
		}
2555
		
2543
		LinkedHashSet resolvedEntries = new LinkedHashSet();
2556
		LinkedHashSet resolvedEntries = new LinkedHashSet();
2544
		int length = rawClasspath.length;
2557
		int length = rawClasspath.length;
2545
		for (int i = 0; i < length; i++) {
2558
		for (int i = 0; i < length; i++) {
Lines 2565-2574 Link Here
2565
							// resolve Class-Path: in manifest
2578
							// resolve Class-Path: in manifest
2566
							ClasspathEntry[] extraEntries = ((ClasspathEntry) resolvedEntry).resolvedChainedLibraries();
2579
							ClasspathEntry[] extraEntries = ((ClasspathEntry) resolvedEntry).resolvedChainedLibraries();
2567
							for (int j = 0, length2 = extraEntries.length; j < length2; j++) {
2580
							for (int j = 0, length2 = extraEntries.length; j < length2; j++) {
2568
								addToResult(rawEntry, extraEntries[j], result, resolvedEntries, externalFoldersManager);
2581
								if (!isLibraryInRawClasspath(rawClasspath, extraEntries[j].getPath())) {
2582
									addToResult(rawEntry, extraEntries[j], result, resolvedEntries, externalFoldersManager, null, null, false);
2583
								}
2569
							}
2584
							}
2570
						}
2585
						}
2571
						addToResult(rawEntry, resolvedEntry, result, resolvedEntries, externalFoldersManager);
2586
						addToResult(rawEntry, resolvedEntry, result, resolvedEntries, externalFoldersManager, null, null, false);
2572
					}
2587
					}
2573
					break;
2588
					break;
2574
2589
Lines 2607-2617 Link Here
2607
								// resolve Class-Path: in manifest
2622
								// resolve Class-Path: in manifest
2608
								ClasspathEntry[] extraEntries = cEntry.resolvedChainedLibraries();
2623
								ClasspathEntry[] extraEntries = cEntry.resolvedChainedLibraries();
2609
								for (int k = 0, length2 = extraEntries.length; k < length2; k++) {
2624
								for (int k = 0, length2 = extraEntries.length; k < length2; k++) {
2610
									addToResult(rawEntry, extraEntries[k], result, resolvedEntries, externalFoldersManager);
2625
									if (!isLibraryInRawClasspath(rawClasspath, extraEntries[k].getPath())) {
2626
										addToResult(rawEntry, extraEntries[k], result, resolvedEntries, externalFoldersManager, null, null, false);
2627
									}
2611
								}
2628
								}
2612
							}
2629
							}
2613
						}
2630
						}
2614
						addToResult(rawEntry, cEntry, result, resolvedEntries, externalFoldersManager);
2631
						addToResult(rawEntry, cEntry, result, resolvedEntries, externalFoldersManager, null, null, false);
2615
					}
2632
					}
2616
					break;
2633
					break;
2617
2634
Lines 2620-2636 Link Here
2620
					resolvedEntry = ((ClasspathEntry) rawEntry).resolvedDotDot();
2637
					resolvedEntry = ((ClasspathEntry) rawEntry).resolvedDotDot();
2621
					
2638
					
2622
					if (resolveChainedLibraries) {
2639
					if (resolveChainedLibraries) {
2623
						// resolve Class-Path: in manifest
2640
						if (rawEntry.excludeChainedJars()) {
2624
						ClasspathEntry[] extraEntries = ((ClasspathEntry) resolvedEntry).resolvedChainedLibraries();
2641
							((ClasspathEntry)rawEntry).setReferencedEntries(null);
2625
						for (int k = 0, length2 = extraEntries.length; k < length2; k++) {
2642
						} else {
2626
							addToResult(rawEntry, extraEntries[k], result, resolvedEntries, externalFoldersManager);
2643
							// resolve Class-Path: in manifest
2644
							ClasspathEntry[] extraEntries = ((ClasspathEntry) resolvedEntry).resolvedChainedLibraries();
2645
							// Set the capacity to the maximum possible, although all of them may not be filled
2646
							List refernecedEntriesList = new ArrayList(extraEntries.length);
2647
							for (int k = 0, length2 = extraEntries.length; k < length2; k++) {
2648
								if (!isLibraryInRawClasspath(rawClasspath, extraEntries[k].getPath())) {
2649
									addToResult(rawEntry, extraEntries[k], result, resolvedEntries,
2650
											externalFoldersManager, oldChainedEntries, refernecedEntriesList, true);
2651
								}
2652
							}
2653
							((ClasspathEntry) rawEntry).setReferencedEntries((IClasspathEntry[]) refernecedEntriesList
2654
									.toArray(new IClasspathEntry[refernecedEntriesList.size()]));
2627
						}
2655
						}
2628
					}
2656
					}
2629
2657
					addToResult(rawEntry, resolvedEntry, result, resolvedEntries, externalFoldersManager, null, null, false);
2630
					addToResult(rawEntry, resolvedEntry, result, resolvedEntries, externalFoldersManager);
2631
					break;
2658
					break;
2632
				default :
2659
				default :
2633
					addToResult(rawEntry, resolvedEntry, result, resolvedEntries, externalFoldersManager);
2660
					addToResult(rawEntry, resolvedEntry, result, resolvedEntries, externalFoldersManager, null, null, false);
2634
					break;
2661
					break;
2635
			}
2662
			}
2636
		}
2663
		}
Lines 2639-2657 Link Here
2639
		return result;
2666
		return result;
2640
	}
2667
	}
2641
2668
2642
	private void addToResult(IClasspathEntry rawEntry, IClasspathEntry resolvedEntry, ResolvedClasspath result, LinkedHashSet resolvedEntries, ExternalFoldersManager externalFoldersManager) {
2669
	private void addToResult(IClasspathEntry rawEntry, IClasspathEntry resolvedEntry, ResolvedClasspath result,
2670
			LinkedHashSet resolvedEntries, ExternalFoldersManager externalFoldersManager, Map oldChainedEntriesMap, List newChainedEntries, boolean addAsChainedEntry) {
2643
		IPath resolvedPath;
2671
		IPath resolvedPath;
2672
		// If it's already been resolved, do not add to resolvedEntries or newChainedEntries lists
2644
		if (result.rawReverseMap.get(resolvedPath = resolvedEntry.getPath()) == null) {
2673
		if (result.rawReverseMap.get(resolvedPath = resolvedEntry.getPath()) == null) {
2674
			IClasspathEntry chainedEntry = null;
2675
			if (addAsChainedEntry) {
2676
				chainedEntry = (ClasspathEntry)oldChainedEntriesMap.get(resolvedPath);
2677
				if (chainedEntry == null) {
2678
					chainedEntry = resolvedEntry;
2679
				}
2680
				else {
2681
					// This is required to keep the attributes if any added by the user in
2682
					// the previous session such as source attachment patch etc.
2683
					copyFromOldChainedEntry(resolvedEntry, chainedEntry);
2684
				}
2685
				newChainedEntries.add(chainedEntry);
2686
			}
2687
2645
			result.rawReverseMap.put(resolvedPath, rawEntry);
2688
			result.rawReverseMap.put(resolvedPath, rawEntry);
2646
			result.rootPathToResolvedEntries.put(resolvedPath, resolvedEntry);
2689
			result.rootPathToResolvedEntries.put(resolvedPath, resolvedEntry);
2690
			resolvedEntries.add(resolvedEntry);
2647
		}
2691
		}
2648
		resolvedEntries.add(resolvedEntry);
2692
2649
		if (resolvedEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY && ExternalFoldersManager.isExternalFolderPath(resolvedPath)) {
2693
		if (resolvedEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY
2694
				&& ExternalFoldersManager.isExternalFolderPath(resolvedPath)) {
2650
			externalFoldersManager.addFolder(resolvedPath); // no-op if not an external folder or if already registered
2695
			externalFoldersManager.addFolder(resolvedPath); // no-op if not an external folder or if already registered
2651
		}
2696
		}
2652
	}
2697
	}
2653
2698
2654
	/*
2699
	/*
2700
	 * Looks for already existing entries in the raw classpath of this project.
2701
	 */
2702
	private boolean isLibraryInRawClasspath(IClasspathEntry[] rawClasspath, IPath entryPath) {
2703
		IPath workspaceRoot = ResourcesPlugin.getWorkspace().getRoot().getLocation();
2704
		for (int index = 0; index < rawClasspath.length; index++) {
2705
			if (rawClasspath[index].getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
2706
				if (rawClasspath[index].getPath().equals(entryPath) ) {
2707
					return true;
2708
				}
2709
				if (workspaceRoot.isPrefixOf(entryPath)) {
2710
					if (rawClasspath[index].getPath().equals(
2711
							entryPath.makeRelativeTo(workspaceRoot).makeAbsolute())) {
2712
						return true;
2713
					}
2714
				}
2715
			}
2716
		}
2717
		return false;
2718
	}	
2719
	
2720
	private void copyFromOldChainedEntry(IClasspathEntry resolvedEntry, IClasspathEntry chainedEntry) {
2721
		IPath path = chainedEntry.getSourceAttachmentPath();
2722
		if ( path != null) {
2723
			((ClasspathEntry) resolvedEntry).sourceAttachmentPath = path;
2724
		}
2725
		path = chainedEntry.getSourceAttachmentRootPath();
2726
		if (path != null) {
2727
			((ClasspathEntry) resolvedEntry).sourceAttachmentRootPath = path;
2728
		}
2729
	}
2730
	
2731
	/*
2655
	 * Resolve the given perProjectInfo's raw classpath and store the resolved classpath in the perProjectInfo.
2732
	 * Resolve the given perProjectInfo's raw classpath and store the resolved classpath in the perProjectInfo.
2656
	 */
2733
	 */
2657
	public void resolveClasspath(PerProjectInfo perProjectInfo, boolean usePreviousSession, boolean addClasspathChange) throws JavaModelException {
2734
	public void resolveClasspath(PerProjectInfo perProjectInfo, boolean usePreviousSession, boolean addClasspathChange) throws JavaModelException {
(-)src/org/eclipse/jdt/core/tests/model/ClasspathTests.java (-1 / +158 lines)
Lines 6020-6026 Link Here
6020
	}	
6020
	}	
6021
}
6021
}
6022
/**
6022
/**
6023
 * Additional test for bug 300136 - Test that the the errors are reported when the 
6023
 * Additional test for bug 300136 - Test that the errors are reported when the 
6024
 * optional attribute is not used.
6024
 * optional attribute is not used.
6025
 * 
6025
 * 
6026
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=300136"
6026
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=300136"
Lines 6056-6060 Link Here
6056
		deleteProject("P");
6056
		deleteProject("P");
6057
	}	
6057
	}	
6058
}
6058
}
6059
public void testBug252341b() throws Exception {
6060
	try {
6061
		IJavaProject p = createJavaProject("P");
6062
		addLibrary(p, "lib1.jar", null, new String[0], 
6063
			new String[] {
6064
				"META-INF/MANIFEST.MF",
6065
				"Manifest-Version: 1.0\n" +
6066
				"Class-Path: lib2.jar lib3.jar\n",
6067
			},
6068
			JavaCore.VERSION_1_4);
6069
		createFile("/P/lib2.jar", "");
6070
		createFile("/P/lib3.jar", "");
6071
		IClasspathEntry[] resolvedClasspath = p.getResolvedClasspath(true);
6072
		assertClasspathEquals(resolvedClasspath, 
6073
				"/P[CPE_SOURCE][K_SOURCE][isExported:false]\n" + 
6074
				""+ getExternalJCLPathString() + "[CPE_LIBRARY][K_BINARY][isExported:false]\n" + 
6075
				"/P/lib2.jar[CPE_LIBRARY][K_BINARY][isExported:true]\n" + 
6076
				"/P/lib3.jar[CPE_LIBRARY][K_BINARY][isExported:true]\n" +
6077
				"/P/lib1.jar[CPE_LIBRARY][K_BINARY][isExported:true]");
6078
		assertClasspathEquals(resolvedClasspath[4].getChainedEntries(), 
6079
				"/P/lib2.jar[CPE_LIBRARY][K_BINARY][isExported:true]\n" + 
6080
				"/P/lib3.jar[CPE_LIBRARY][K_BINARY][isExported:true]");
6081
	} finally {
6082
		deleteProject("P");
6083
	}
6084
}
6085
public void testBug252341c() throws Exception {
6086
	try {
6087
		IJavaProject p = createJavaProject("P");
6088
		addLibrary(p, "lib1.jar", null, new String[0], 
6089
			new String[] {
6090
				"META-INF/MANIFEST.MF",
6091
				"Manifest-Version: 1.0\n" +
6092
				"Class-Path: lib3.jar lib4.jar\n",
6093
			},
6094
			JavaCore.VERSION_1_4);
6095
		
6096
		addLibrary(p, "lib2.jar", null, new String[0], 
6097
				new String[] {
6098
					"META-INF/MANIFEST.MF",
6099
					"Manifest-Version: 1.0\n" +
6100
					"Class-Path: lib3.jar lib5.jar\n",
6101
				},
6102
				JavaCore.VERSION_1_4);
6103
		createFile("/P/lib3.jar", "");
6104
		createFile("/P/lib4.jar", "");
6105
		createFile("/P/lib5.jar", "");
6106
		
6107
		IClasspathEntry[] resolvedClasspath = p.getResolvedClasspath(true);
6108
		assertClasspathEquals(resolvedClasspath, 
6109
				"/P[CPE_SOURCE][K_SOURCE][isExported:false]\n" + 
6110
				""+ getExternalJCLPathString() + "[CPE_LIBRARY][K_BINARY][isExported:false]\n" + 
6111
				"/P/lib3.jar[CPE_LIBRARY][K_BINARY][isExported:true]\n" + 
6112
				"/P/lib4.jar[CPE_LIBRARY][K_BINARY][isExported:true]\n" + 
6113
				"/P/lib1.jar[CPE_LIBRARY][K_BINARY][isExported:true]\n" + 
6114
				"/P/lib5.jar[CPE_LIBRARY][K_BINARY][isExported:true]\n" + 
6115
				"/P/lib2.jar[CPE_LIBRARY][K_BINARY][isExported:true]");
6116
		assertClasspathEquals(
6117
				resolvedClasspath[4].getChainedEntries(), 
6118
				"/P/lib3.jar[CPE_LIBRARY][K_BINARY][isExported:true]\n" + 
6119
				"/P/lib4.jar[CPE_LIBRARY][K_BINARY][isExported:true]");
6120
		assertClasspathEquals(
6121
				resolvedClasspath[6].getChainedEntries(), 
6122
				"/P/lib5.jar[CPE_LIBRARY][K_BINARY][isExported:true]");
6123
	} finally {
6124
		deleteProject("P");
6125
	}
6126
}
6127
public void testBug252341d() throws Exception {
6128
	try {
6129
		IJavaProject p = createJavaProject("P");
6130
		addLibrary(p, "lib1.jar", null, new String[0], 
6131
			new String[] {
6132
				"META-INF/MANIFEST.MF",
6133
				"Manifest-Version: 1.0\n" +
6134
				"Class-Path: lib3.jar lib4.jar\n",
6135
			},
6136
			JavaCore.VERSION_1_4);
6137
		
6138
		addLibrary(p, "lib2.jar", null, new String[0], 
6139
				new String[] {
6140
					"META-INF/MANIFEST.MF",
6141
					"Manifest-Version: 1.0\n" +
6142
					"Class-Path: lib3.jar lib5.jar\n",
6143
				},
6144
				JavaCore.VERSION_1_4);
6145
		createFile("/P/lib3.jar", "");
6146
		createFile("/P/lib4.jar", "");
6147
		createFile("/P/lib5.jar", "");
6148
		
6149
		IClasspathEntry[] rawClasspath = p.getRawClasspath();
6150
		assertClasspathEquals(
6151
				rawClasspath,
6152
				"/P[CPE_SOURCE][K_SOURCE][isExported:false]\n" + 
6153
				"JCL_LIB[CPE_VARIABLE][K_SOURCE][isExported:false]\n" + 
6154
				"/P/lib1.jar[CPE_LIBRARY][K_BINARY][isExported:true]\n" + 
6155
				"/P/lib2.jar[CPE_LIBRARY][K_BINARY][isExported:true]");
6156
6157
		IClasspathEntry[] resolvedClasspath = p.getResolvedClasspath(true);
6158
		assertClasspathEquals(resolvedClasspath, 
6159
				"/P[CPE_SOURCE][K_SOURCE][isExported:false]\n" + 
6160
				""+ getExternalJCLPathString() + "[CPE_LIBRARY][K_BINARY][isExported:false]\n" + 
6161
				"/P/lib3.jar[CPE_LIBRARY][K_BINARY][isExported:true]\n" + 
6162
				"/P/lib4.jar[CPE_LIBRARY][K_BINARY][isExported:true]\n" + 
6163
				"/P/lib1.jar[CPE_LIBRARY][K_BINARY][isExported:true]\n" + 
6164
				"/P/lib5.jar[CPE_LIBRARY][K_BINARY][isExported:true]\n" + 
6165
				"/P/lib2.jar[CPE_LIBRARY][K_BINARY][isExported:true]");
6059
6166
6167
		assertClasspathEquals(
6168
				resolvedClasspath[4].getChainedEntries(), 
6169
				"/P/lib3.jar[CPE_LIBRARY][K_BINARY][isExported:true]\n" + 
6170
				"/P/lib4.jar[CPE_LIBRARY][K_BINARY][isExported:true]");
6171
		assertClasspathEquals(
6172
				resolvedClasspath[6].getChainedEntries(), 
6173
				"/P/lib5.jar[CPE_LIBRARY][K_BINARY][isExported:true]");
6174
		
6175
		((ClasspathEntry)rawClasspath[2]).excludeChainedJars = true;
6176
		p.setRawClasspath(rawClasspath, null);
6177
		resolvedClasspath = p.getResolvedClasspath(true);
6178
		
6179
		assertClasspathEquals(resolvedClasspath, 
6180
				"/P[CPE_SOURCE][K_SOURCE][isExported:false]\n" + 
6181
				""+ getExternalJCLPathString() + "[CPE_LIBRARY][K_BINARY][isExported:false]\n" + 
6182
				"/P/lib1.jar[CPE_LIBRARY][K_BINARY][isExported:true]\n" + 
6183
				"/P/lib3.jar[CPE_LIBRARY][K_BINARY][isExported:true]\n" + 
6184
				"/P/lib5.jar[CPE_LIBRARY][K_BINARY][isExported:true]\n" + 
6185
				"/P/lib2.jar[CPE_LIBRARY][K_BINARY][isExported:true]");
6186
		
6187
		//Flip it back to false
6188
		((ClasspathEntry)rawClasspath[2]).excludeChainedJars = false;
6189
		p.setRawClasspath(rawClasspath, null);
6190
		resolvedClasspath = p.getResolvedClasspath(true);
6191
		
6192
		assertClasspathEquals(resolvedClasspath, 
6193
				"/P[CPE_SOURCE][K_SOURCE][isExported:false]\n" + 
6194
				""+ getExternalJCLPathString() + "[CPE_LIBRARY][K_BINARY][isExported:false]\n" + 
6195
				"/P/lib3.jar[CPE_LIBRARY][K_BINARY][isExported:true]\n" + 
6196
				"/P/lib4.jar[CPE_LIBRARY][K_BINARY][isExported:true]\n" + 
6197
				"/P/lib1.jar[CPE_LIBRARY][K_BINARY][isExported:true]\n" + 
6198
				"/P/lib5.jar[CPE_LIBRARY][K_BINARY][isExported:true]\n" + 
6199
				"/P/lib2.jar[CPE_LIBRARY][K_BINARY][isExported:true]");
6200
		
6201
		//Remove the first jar entirely from the classpath
6202
		IClasspathEntry[] newRawClasspath = new IClasspathEntry[rawClasspath.length-1];
6203
		System.arraycopy(rawClasspath, 0, newRawClasspath, 0, 2);
6204
		System.arraycopy(rawClasspath, 3, newRawClasspath, 2, 1);
6205
		p.setRawClasspath(newRawClasspath, null);
6206
		resolvedClasspath = p.getResolvedClasspath(true);
6207
		assertClasspathEquals(resolvedClasspath, 
6208
				"/P[CPE_SOURCE][K_SOURCE][isExported:false]\n" + 
6209
				""+ getExternalJCLPathString() + "[CPE_LIBRARY][K_BINARY][isExported:false]\n" + 
6210
				"/P/lib3.jar[CPE_LIBRARY][K_BINARY][isExported:true]\n" + 
6211
				"/P/lib5.jar[CPE_LIBRARY][K_BINARY][isExported:true]\n" + 
6212
				"/P/lib2.jar[CPE_LIBRARY][K_BINARY][isExported:true]");
6213
	} finally {
6214
		deleteProject("P");
6215
	}
6216
}
6060
}
6217
}
(-)ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/CPListElement.java (-3 / +13 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 49-55 Link Here
49
	public static final String OUTPUT= "output"; //$NON-NLS-1$
49
	public static final String OUTPUT= "output"; //$NON-NLS-1$
50
	public static final String EXCLUSION= "exclusion"; //$NON-NLS-1$
50
	public static final String EXCLUSION= "exclusion"; //$NON-NLS-1$
51
	public static final String INCLUSION= "inclusion"; //$NON-NLS-1$
51
	public static final String INCLUSION= "inclusion"; //$NON-NLS-1$
52
52
	public static final String CHAINED_JARS= "chainedjars"; //$NON-NLS-1$
53
	public static final String EXCLUDE_CHAINS="exclude_chains"; //$NON-NLS-1$
53
	public static final String ACCESSRULES= "accessrules"; //$NON-NLS-1$
54
	public static final String ACCESSRULES= "accessrules"; //$NON-NLS-1$
54
	public static final String COMBINE_ACCESSRULES= "combineaccessrules"; //$NON-NLS-1$
55
	public static final String COMBINE_ACCESSRULES= "combineaccessrules"; //$NON-NLS-1$
55
56
Lines 112-117 Link Here
112
				createAttributeElement(NATIVE_LIB_PATH, null, false);
113
				createAttributeElement(NATIVE_LIB_PATH, null, false);
113
				break;
114
				break;
114
			case IClasspathEntry.CPE_LIBRARY:
115
			case IClasspathEntry.CPE_LIBRARY:
116
				createAttributeElement(CHAINED_JARS, null, true);
117
				createAttributeElement(EXCLUDE_CHAINS, Boolean.FALSE, true);
118
				//$FALL-THROUGH$
115
			case IClasspathEntry.CPE_VARIABLE:
119
			case IClasspathEntry.CPE_VARIABLE:
116
				createAttributeElement(SOURCEATTACHMENT, null, true);
120
				createAttributeElement(SOURCEATTACHMENT, null, true);
117
				createAttributeElement(JAVADOC, null, false);
121
				createAttributeElement(JAVADOC, null, false);
Lines 185-192 Link Here
185
				return JavaCore.newSourceEntry(fPath, inclusionPattern, exclusionPattern, outputLocation, extraAttributes);
189
				return JavaCore.newSourceEntry(fPath, inclusionPattern, exclusionPattern, outputLocation, extraAttributes);
186
			case IClasspathEntry.CPE_LIBRARY: {
190
			case IClasspathEntry.CPE_LIBRARY: {
187
				IPath attach= (IPath) getAttribute(SOURCEATTACHMENT);
191
				IPath attach= (IPath) getAttribute(SOURCEATTACHMENT);
192
				IClasspathEntry[] referencedJars = (IClasspathEntry[]) getAttribute(CHAINED_JARS);
193
				boolean excludeChainedJars = ((Boolean) getAttribute(EXCLUDE_CHAINS)).booleanValue();
188
				IAccessRule[] accesRules= (IAccessRule[]) getAttribute(ACCESSRULES);
194
				IAccessRule[] accesRules= (IAccessRule[]) getAttribute(ACCESSRULES);
189
				return JavaCore.newLibraryEntry(fPath, attach, null, accesRules, extraAttributes, isExported());
195
				return JavaCore.newLibraryEntry(fPath, attach, null, referencedJars, excludeChainedJars, accesRules, extraAttributes, isExported());
190
			}
196
			}
191
			case IClasspathEntry.CPE_PROJECT: {
197
			case IClasspathEntry.CPE_PROJECT: {
192
				IAccessRule[] accesRules= (IAccessRule[]) getAttribute(ACCESSRULES);
198
				IAccessRule[] accesRules= (IAccessRule[]) getAttribute(ACCESSRULES);
Lines 625-630 Link Here
625
		elem.setAttribute(INCLUSION, curr.getInclusionPatterns());
631
		elem.setAttribute(INCLUSION, curr.getInclusionPatterns());
626
		elem.setAttribute(ACCESSRULES, curr.getAccessRules());
632
		elem.setAttribute(ACCESSRULES, curr.getAccessRules());
627
		elem.setAttribute(COMBINE_ACCESSRULES, new Boolean(curr.combineAccessRules()));
633
		elem.setAttribute(COMBINE_ACCESSRULES, new Boolean(curr.combineAccessRules()));
634
		elem.setAttribute(CHAINED_JARS, curr.getChainedEntries());
635
		elem.setAttribute(EXCLUDE_CHAINS, new Boolean(curr.excludeChainedJars()));
628
636
629
		IClasspathAttribute[] extraAttributes= curr.getExtraAttributes();
637
		IClasspathAttribute[] extraAttributes= curr.getExtraAttributes();
630
		for (int i= 0; i < extraAttributes.length; i++) {
638
		for (int i= 0; i < extraAttributes.length; i++) {
Lines 709-714 Link Here
709
						appendEncodedAccessRules((IAccessRule[]) elem.getValue(), buf).append(';');
717
						appendEncodedAccessRules((IAccessRule[]) elem.getValue(), buf).append(';');
710
					} else if (COMBINE_ACCESSRULES.equals(key)) {
718
					} else if (COMBINE_ACCESSRULES.equals(key)) {
711
						buf.append(((Boolean) elem.getValue()).booleanValue()).append(';');
719
						buf.append(((Boolean) elem.getValue()).booleanValue()).append(';');
720
					} else if (EXCLUDE_CHAINS.equals(key)) {
721
						buf.append(((Boolean) elem.getValue()).booleanValue()).append(';');
712
					}
722
					}
713
				} else {
723
				} else {
714
					appendEncodedString((String) elem.getValue(), buf);
724
					appendEncodedString((String) elem.getValue(), buf);

Return to bug 252431