/[packages]/cauldron/xerces-j2/current/SOURCES/XJavac.java
ViewVC logotype

Contents of /cauldron/xerces-j2/current/SOURCES/XJavac.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 17862 - (show annotations) (download)
Fri Jan 14 19:54:19 2011 UTC (13 years, 3 months ago) by ahmad
File size: 6581 byte(s)
imported package xerces-j2
1 /*
2 * Copyright 2001-2005 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package org.apache.xerces.util;
18
19 import org.apache.tools.ant.BuildException;
20 import org.apache.tools.ant.Project;
21 import org.apache.tools.ant.types.Path;
22 import org.apache.tools.ant.util.JavaEnvUtils;
23 import org.apache.tools.ant.taskdefs.Javac;
24
25 import java.lang.StringBuffer;
26 import java.util.Properties;
27 import java.util.Locale;
28
29 /**
30 * The implementation of the javac compiler for IBM JDK 1.4
31 *
32 * The purpose of this task is to diagnose whether we're
33 * running on an IBM 1.4 JVM; if we are, to
34 * set up the bootclasspath such that the build will
35 * succeed; if we aren't, then invoke the Javac12
36 * task.
37 *
38 * @author Neil Graham, IBM
39 */
40
41 public class XJavac extends Javac {
42
43 /**
44 * Run the compilation.
45 *
46 * @exception BuildException if the compilation has problems.
47 */
48 public void execute() throws BuildException {
49 if(isJDK14OrHigher()) {
50 // maybe the right one; check vendor:
51 // by checking system properties:
52 Properties props = null;
53 try {
54 props = System.getProperties();
55 } catch (Exception e) {
56 throw new BuildException("unable to determine java vendor because could not access system properties!");
57 }
58 // this is supposed to be provided by all JVM's from time immemorial
59 String vendor = ((String)props.get("java.vendor")).toUpperCase(Locale.ENGLISH);
60 if(vendor.indexOf("IBM") >= 0){
61 // we're on an IBM 1.4; fiddle with the bootclasspath.
62 Path bcp = createBootclasspath();
63 String javaHome = System.getProperty("java.home");
64 StringBuffer bcpMember = new StringBuffer();
65 bcpMember.append(javaHome).append("/lib/charsets.jar:");
66 bcp.createPathElement().setPath(bcpMember.toString());
67 bcpMember.replace(javaHome.length(), bcpMember.length(), "/lib/core.jar:");
68 bcp.createPathElement().setPath(bcpMember.toString());
69 bcpMember.replace(javaHome.length(), bcpMember.length(), "/lib/graphics.jar:");
70 bcp.createPathElement().setPath(bcpMember.toString());
71 bcpMember.replace(javaHome.length(), bcpMember.length(), "/lib/javaws.jar:");
72 bcp.createPathElement().setPath(bcpMember.toString());
73 bcpMember.replace(javaHome.length(), bcpMember.length(), "/lib/jaws.jar:");
74 bcp.createPathElement().setPath(bcpMember.toString());
75 bcpMember.replace(javaHome.length(), bcpMember.length(), "/lib/security.jar:");
76 bcp.createPathElement().setPath(bcpMember.toString());
77 bcpMember.replace(javaHome.length(), bcpMember.length(), "/lib/server.jar:");
78 bcp.createPathElement().setPath(bcpMember.toString());
79 bcpMember.replace(javaHome.length(), bcpMember.length(), "/lib/ext/JawBridge.jar:");
80 bcp.createPathElement().setPath(bcpMember.toString());
81 bcpMember.replace(javaHome.length(), bcpMember.length(), "/lib/ext/gskikm.jar:");
82 bcp.createPathElement().setPath(bcpMember.toString());
83 bcpMember.replace(javaHome.length(), bcpMember.length(), "/lib/ext/ibmjceprovider.jar:");
84 bcp.createPathElement().setPath(bcpMember.toString());
85 bcpMember.replace(javaHome.length(), bcpMember.length(), "/lib/ext/indicim.jar:");
86 bcp.createPathElement().setPath(bcpMember.toString());
87 bcpMember.replace(javaHome.length(), bcpMember.length(), "/lib/ext/jaccess.jar:");
88 bcp.createPathElement().setPath(bcpMember.toString());
89 bcpMember.replace(javaHome.length(), bcpMember.length(), "/lib/ext/ldapsec.jar:");
90 bcp.createPathElement().setPath(bcpMember.toString());
91 bcpMember.replace(javaHome.length(), bcpMember.length(), "/lib/ext/oldcertpath.jar");
92 bcp.createPathElement().setPath(bcpMember.toString());
93 setBootclasspath(bcp);
94 }
95 // need to do special things for Sun too and also
96 // for Apple, HP and Blackdown: a Linux port of Sun Java
97 else if( (vendor.indexOf("SUN") >= 0) ||
98 (vendor.indexOf("BLACKDOWN") >= 0) ||
99 (vendor.indexOf("APPLE") >= 0) ||
100 (vendor.indexOf("HEWLETT-PACKARD") >= 0)) {
101 // we're on an SUN 1.4; fiddle with the bootclasspath.
102 // since we can't eviscerate XML-related info here,
103 // we must use the classpath
104 Path bcp = createBootclasspath();
105 Path clPath = getClasspath();
106 bcp.append(clPath);
107 String currBCP = (String)props.get("sun.boot.class.path");
108 Path currBCPath = new Path(null);
109 currBCPath.createPathElement().setPath(currBCP);
110 bcp.append(currBCPath);
111 setBootclasspath(bcp);
112 }
113 }
114 // now just do the normal thing:
115 super.execute();
116 }
117
118 /**
119 * Checks whether the JDK version is 1.4 or higher. If it's not
120 * JDK 1.4 we check whether we're on a future JDK by checking
121 * that we're not on JDKs 1.0, 1.1, 1.2 or 1.3. This check by
122 * exclusion should future proof this task from new versions of
123 * Ant which are aware of higher JDK versions.
124 *
125 * @return true if the JDK version is 1.4 or higher.
126 */
127 private boolean isJDK14OrHigher() {
128 final String version = JavaEnvUtils.getJavaVersion();
129 return version.equals(JavaEnvUtils.JAVA_1_4) ||
130 (!version.equals(JavaEnvUtils.JAVA_1_3) &&
131 !version.equals(JavaEnvUtils.JAVA_1_2) &&
132 !version.equals(JavaEnvUtils.JAVA_1_1) &&
133 !version.equals(JavaEnvUtils.JAVA_1_0));
134 }
135 }

  ViewVC Help
Powered by ViewVC 1.1.30