1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
*
* Copyright 2003, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute for Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* $Id: OTRuntimeClasspathProvider.java 21932 2009-07-30 16:53:44Z stephan $
*
* Please visit http://www.eclipse.org/objectteams for updates and contact.
*
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
**********************************************************************/
package org.eclipse.objectteams.otdt.core.ext;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jdt.launching.StandardClasspathProvider;
/**
* @author gis
* @version $Id: OTRuntimeClasspathProvider.java 21932 2009-07-30 16:53:44Z stephan $
*/
public class OTRuntimeClasspathProvider extends StandardClasspathProvider
{
public static final String PROVIDER_ID = "org.eclipse.objectteams.otdt.OTRuntimeClasspathProvider"; //$NON-NLS-1$
public IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration configuration) throws CoreException
{
// add BCEL, JMangler-core and JMangler-start (classpath / bootclasspath)
IRuntimeClasspathEntry[] origEntries = super.computeUnresolvedClasspath(configuration);
int oldLength = origEntries.length;
IRuntimeClasspathEntry[] otRuntimeEntries = computePathsToAdd(origEntries);
IRuntimeClasspathEntry[] result = new IRuntimeClasspathEntry[oldLength + otRuntimeEntries.length];
System.arraycopy(origEntries, 0, result, 0, oldLength);
// add the missing OT runtime paths to the result
for (int i = 0; i < otRuntimeEntries.length; i++)
{
result[oldLength + i] = otRuntimeEntries[i];
}
// IJavaProject project = JavaRuntime.getJavaProject(configuration);
// if (project == null) {
// // no project - use JRE's libraries by default
return result;
}
private static IRuntimeClasspathEntry[] computePathsToAdd( IRuntimeClasspathEntry[] origEntries )
{
boolean hasBCEL = false;
boolean hasJManglerCore = false;
boolean hasJManglerStart = false;
for (int i = 0; i < origEntries.length; i++)
{
IRuntimeClasspathEntry entry = origEntries[i];
if (OTREContainer.BCEL_JAR.equals(entry.getPath()))
hasBCEL = true;
}
List<IRuntimeClasspathEntry> result = new LinkedList<IRuntimeClasspathEntry>();
IRuntimeClasspathEntry entry;
//TODO (carp): make these class paths variable classpaths and compute the absolute path later
// Also fix getVariablePath() then.
if (!hasBCEL)
{
entry = JavaRuntime.newArchiveRuntimeClasspathEntry(OTREContainer.BCEL_JAR);
entry.setClasspathProperty(IRuntimeClasspathEntry.BOOTSTRAP_CLASSES);
result.add(entry);
}
if (!hasJManglerCore)
{
throw new RuntimeException("JMangler is no longer supported");
}
if (!hasJManglerStart)
{
throw new RuntimeException("JMangler is no longer supported");
}
return result.toArray(new IRuntimeClasspathEntry[result.size()]);
}
public IRuntimeClasspathEntry[] resolveClasspath(
IRuntimeClasspathEntry[] entries,
ILaunchConfiguration configuration)
throws CoreException
{
IRuntimeClasspathEntry[] result = super.resolveClasspath(entries, configuration);
return result;
}
}
|