Skip to content

Commit b4b30b8

Browse files
committed
New platform jar with java 8 mac code
1 parent 1166375 commit b4b30b8

File tree

11 files changed

+437
-0
lines changed

11 files changed

+437
-0
lines changed

drjava/lib/platform.jar

-3 Bytes
Binary file not shown.

platform/build.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@
158158
that is not possible, later versions are used. Note that if there are dependencies on
159159
later APIs, the DrJava application is responsible for ensuring that those classes are
160160
only loaded when the necessary APIs are available. -->
161+
162+
<target name="compile-all" depends="compile-eclipse, compile-hj, compile-jdk5, compile-jdk6, compile-jdk7, compile-mac, compile-mac-java-8, compile-mint, compile-nextgen, compile-openjdk6, compile-windows"
163+
description="Run all compile targets"/>
161164

162165
<target name="compile-jdk5" depends="resolve-java5-runtime, resolve-java5-tools"
163166
description="Compile the 'jdk5' sources">
@@ -248,6 +251,16 @@
248251
<!-- <param name="extra-classpath" value="${java8-runtime}/../ui.jar" />-->
249252
</antcall>
250253
</target>
254+
255+
<target name="compile-mac-java-8" depends="resolve-java8-runtime"
256+
description="Compile the 'mac-java-8' sources">
257+
<antcall target="do-compile">
258+
<param name="platform-tag" value="mac-java-8" />
259+
<param name="source-version" value="1.8" />
260+
<param name="runtime-jar" value="${java8-runtime}" />
261+
<param name="extra-classpath" value="${java8-runtime}/../ui.jar" />
262+
</antcall>
263+
</target>
251264

252265
<target name="compile-windows" depends="resolve-java5-runtime"
253266
description="Compile the 'windows' sources">
@@ -491,6 +504,15 @@
491504
</antcall>
492505
</target>
493506

507+
<target name="test-mac-java-8" depends="compile-mac-java-8"
508+
description="Run all 'mac' tests (after compiling); use -Dtest-spec=... to filter">
509+
<antcall target="iterate-tests">
510+
<param name="platform-tag" value="mac-java-8" />
511+
<param name="extra-classpath" value="" />
512+
<param name="test-jvm" value="java" />
513+
</antcall>
514+
</target>
515+
494516
<target name="test-windows" depends="compile-windows"
495517
description="Run all 'windows' tests (after compiling); use -Dtest-spec=... to filter">
496518
<antcall target="iterate-tests">
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
/*BEGIN_COPYRIGHT_BLOCK
2+
*
3+
* Copyright (c) 2001-2010, JavaPLT group at Rice University (drjava@rice.edu)
4+
* All rights reserved.
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions are met:
8+
* * Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* * Redistributions in binary form must reproduce the above copyright
11+
* notice, this list of conditions and the following disclaimer in the
12+
* documentation and/or other materials provided with the distribution.
13+
* * Neither the names of DrJava, the JavaPLT group, Rice University, nor the
14+
* names of its contributors may be used to endorse or promote products
15+
* derived from this software without specific prior written permission.
16+
*
17+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*
29+
* This software is Open Source Initiative approved Open Source Software.
30+
* Open Source Initative Approved is a trademark of the Open Source Initiative.
31+
*
32+
* This file is part of DrJava. Download the current version of this project
33+
* from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/
34+
*
35+
* END_COPYRIGHT_BLOCK*/
36+
37+
package edu.rice.cs.drjava.model.compiler.descriptors;
38+
39+
import java.io.File;
40+
import java.io.FileNotFoundException;
41+
import java.io.IOException;
42+
import java.util.Set;
43+
import java.util.HashSet;
44+
import java.util.Collections;
45+
import java.util.jar.JarFile;
46+
import edu.rice.cs.plt.reflect.JavaVersion;
47+
import edu.rice.cs.plt.iter.IterUtil;
48+
import edu.rice.cs.plt.io.IOUtil;
49+
import edu.rice.cs.plt.lambda.LambdaUtil;
50+
import edu.rice.cs.plt.lambda.Predicate;
51+
52+
import edu.rice.cs.drjava.model.JDKDescriptor;
53+
54+
/** The description of the SoyLatte JDK. */
55+
public class SoyLatteDescriptor extends JDKDescriptor {
56+
/** Return the name of this JDK.
57+
* @return name */
58+
public String getName() {
59+
return "SoyLatte";
60+
}
61+
62+
/** Packages to shadow when loading a new tools.jar. If we don't shadow these classes, we won't
63+
* be able to load distinct versions for each tools.jar library. These should be verified whenever
64+
* a new Java version is released. (We can't just shadow *everything* because some classes, at
65+
* least in OS X's classes.jar, can only be loaded by the JVM.)
66+
*
67+
* @return set of packages that need to be shadowed
68+
*/
69+
public Set<String> getToolsPackages() {
70+
HashSet<String> set = new HashSet<String>();
71+
Collections.addAll(set, new String[] {
72+
// Additional from 6 tools.jar:
73+
"com.sun.codemodel",
74+
"com.sun.istack.internal.tools", // other istack packages are in rt.jar
75+
"com.sun.istack.internal.ws",
76+
"com.sun.source",
77+
"com.sun.xml.internal.dtdparser", // other xml.internal packages are in rt.jar
78+
"com.sun.xml.internal.rngom",
79+
"com.sun.xml.internal.xsom",
80+
"org.relaxng",
81+
"javax.lang.element"
82+
});
83+
return set;
84+
}
85+
86+
/** Returns a list of directories that should be searched for tools.jar and classes.jar files.
87+
* @return list of directories to search */
88+
public Iterable<File> getSearchDirectories() {
89+
if (System.getProperty("os.name").toLowerCase().indexOf("mac")<0) return IterUtil.empty(); // Mac only
90+
Iterable<File> roots = IterUtil.asIterable(new File[] {
91+
new File("/usr/local/soylatte"),
92+
new File("/usr/local")
93+
});
94+
Predicate<File> subdirFilter = LambdaUtil.or(IOUtil.regexCanonicalCaseFilePredicate("\\d+\\.\\d+\\.\\d+"),
95+
IOUtil.regexCanonicalCaseFilePredicate("soylatte.*"));
96+
Iterable<File> dirs = IterUtil.empty();
97+
for(File d: roots) {
98+
dirs = IterUtil.compose(dirs, IOUtil.attemptListFilesAsIterable(d, subdirFilter));
99+
}
100+
return dirs;
101+
}
102+
103+
/** Returns a list of files that should be searched if they contain a compiler.
104+
* @return list of files to search */
105+
public Iterable<File> getSearchFiles() {
106+
if (System.getProperty("os.name").toLowerCase().indexOf("mac")<0) return IterUtil.empty(); // Mac only
107+
return IterUtil.asIterable(new File[] {
108+
new File("/usr/local/soylatte/lib/classes.jar"),
109+
new File("/usr/local/soylatte/lib/tools.jar")
110+
});
111+
}
112+
113+
/** True if this is a compound JDK and needs a fully featured JDK to operate.
114+
* @return true if compound JDK (e.g. NextGen, Mint, Habanero). */
115+
public boolean isCompound() { return false; }
116+
117+
/** Return true if the file (jar file or directory) contains the compiler.
118+
* @return true if the file contains the compiler */
119+
public boolean containsCompiler(File f) {
120+
if (System.getProperty("os.name").toLowerCase().indexOf("mac")<0) return false; // Mac only
121+
return Util.exists(f,
122+
"sun/tools/javac/Main.class",
123+
"com/sun/tools/javac/main/JavaCompiler.class",
124+
"com/sun/tools/javac/util/Context.class",
125+
"com/sun/tools/javac/util/Name.class",
126+
"com/sun/tools/javac/util/Options.class",
127+
"com/sun/tools/javac/util/Position.class");
128+
}
129+
130+
/** Return the class name of the compiler adapter.
131+
* @return class name of compiler, or null if no compiler */
132+
public String getAdapterForCompiler() { return "edu.rice.cs.drjava.model.compiler.Javac160Compiler"; }
133+
134+
/** Return the class name of the debugger adapter.
135+
* @return class name of debugger, or null if no debugger */
136+
public String getAdapterForDebugger() { return null; }
137+
138+
/** Return the minimum Java version required to use this JDK.
139+
* @return minimum version */
140+
public JavaVersion getMinimumMajorVersion() { return JavaVersion.JAVA_6; }
141+
142+
/** Return the list of additional files required to use the compiler.
143+
* The compiler was found in the specified file. This method may have to search the user's hard drive, e.g.
144+
* by looking relative to compiler.getParentFile(), by checking environment variables, or by looking in
145+
* certain OS-specific directories.
146+
* @param compiler location where the compiler was fund
147+
* @return list of additional files that need to be available */
148+
public Iterable<File> getAdditionalCompilerFiles(File compiler) throws FileNotFoundException {
149+
File parentDir = compiler.getParentFile();
150+
return IterUtil.make(Util.oneOf(parentDir, "../jre/lib/rt.jar"));
151+
}
152+
153+
public String toString() { return getClass().getSimpleName()+" --> "+getAdapterForCompiler(); }
154+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*BEGIN_COPYRIGHT_BLOCK
2+
*
3+
* Copyright (c) 2001-2010, JavaPLT group at Rice University (drjava@rice.edu)
4+
* All rights reserved.
5+
*
6+
* Redistribution and use in source and binary forms, with or without
7+
* modification, are permitted provided that the following conditions are met:
8+
* * Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* * Redistributions in binary form must reproduce the above copyright
11+
* notice, this list of conditions and the following disclaimer in the
12+
* documentation and/or other materials provided with the distribution.
13+
* * Neither the names of DrJava, the JavaPLT group, Rice University, nor the
14+
* names of its contributors may be used to endorse or promote products
15+
* derived from this software without specific prior written permission.
16+
*
17+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*
29+
* This software is Open Source Initiative approved Open Source Software.
30+
* Open Source Initative Approved is a trademark of the Open Source Initiative.
31+
*
32+
* This file is part of DrJava. Download the current version of this project
33+
* from http://www.drjava.org/ or http://sourceforge.net/projects/drjava/
34+
*
35+
* END_COPYRIGHT_BLOCK*/
36+
37+
package edu.rice.cs.drjava.platform;
38+
39+
import junit.framework.*;
40+
41+
/**
42+
* A simple test class to verify that PlatformFactory has returned the appropriate
43+
* PlatformSupport class.
44+
*/
45+
public class MacJava8FactoryTest extends TestCase {
46+
/**
47+
* Gets the PlatformSupport implementation for this platform from the
48+
* PlatformFactory and verifies that it is an instance of the correct
49+
* class.
50+
*/
51+
public void testFactory() {
52+
PlatformSupport ps = PlatformFactory.ONLY;
53+
String psClassName = ps.getClass().getName();
54+
assertEquals("PlatformFactory produced the appropriate PlatformSupport?",
55+
"edu.rice.cs.drjava.platform.MacPlatformJava8",
56+
psClassName);
57+
}
58+
}

0 commit comments

Comments
 (0)