/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* ExtCheck reports on clashes between a specified (target)
* jar file and jar files already installed in the extensions
* directory.
*
* @author Benedict Gomes
* @since 1.2
*/
public class ExtCheck {
private static final boolean DEBUG = false;
// The following strings hold the values of the version variables
// for the target jar file
/* Flag to indicate whether extra information should be dumped to stdout */
private boolean verboseFlag;
/*
* Create a new instance of the jar reporting tool for a particular
* targetFile.
* @param targetFile is the file to compare against.
* @param verbose indicates whether to dump filenames and manifest
* information (on conflict) to the standard output.
*/
}
}
try {
}
} catch (MalformedURLException e){
error("Malformed URL ");
} catch (IOException e) {
error("IO Exception ");
}
if (targetManifest == null)
} else {
error("No attributes available in the manifest");
}
if (targetSpecTitle == null)
error("The target file does not have a specification title");
if (targetSpecVersion == null)
error("The target file does not have a specification version");
if (targetSpecVendor != null)
if (targetImplVersion != null)
if (targetImplVendor != null)
verboseMessage("");
}
/**
* Verify that none of the jar files in the install directory
* has the same specification-title and the same or a newer
* specification-version.
*
* @return Return true if the target jar file is newer
* than any installed jar file with the same specification-title,
* otherwise return false
*/
boolean checkInstalledAgainstTarget(){
if (s != null) {
for (int i = 0; i < count; i++) {
}
} else {
}
boolean result = true;
try {
}
} catch (MalformedURLException e){
error("Malformed URL");
} catch (IOException e) {
error("IO Exception");
}
}
}
}
if (result) {
generalMessage("No conflicting installed jar found.");
} else {
generalMessage("Conflicting installed jar found. "
+ " Use -verbose for more information.");
}
return result;
}
/**
* Recursively verify that a jar file, and any urls mentioned
* in its class path, do not conflict with the target jar file.
*
* @param indent is the current nesting level
* @param url is the path to the jar file being checked.
* @return true if there is no newer URL, otherwise false
*/
throws IOException
{
verboseMessage("");
verboseMessage("CONFLICT DETECTED ");
verboseMessage("Installed Version:" +
version);
verboseMessage("Implementation Title:"+
if (implVersion != null)
verboseMessage("Implementation Version:"+
if (implVendor != null)
verboseMessage("Implementation Vendor:"+
return false;
}
}
}
}
}
}
boolean result = true;
if (loaderList != null) {
}
}
}
return result;
}
/**
* See comment in method java.lang.Package.isCompatibleWith.
* Return true if already is not older than target. i.e. the
* target file may be superseded by a file already installed
*/
throws NumberFormatException
{
throw new NumberFormatException("Empty version string");
}
// Until it matches scan and compare numbers
int dver;
int sver;
if (dtok.hasMoreTokens()) {
} else
dver = 0;
if (stok.hasMoreTokens()) {
} else
sver = 0;
return false; // Known to be incompatible
return true; // Known to be compatible
// Check for and absorb separators
if (dtok.hasMoreTokens())
if (stok.hasMoreTokens())
// Compare next component
}
// All components numerically equal
return true;
}
/**
* Prints out message if the verboseFlag is set
*/
if (verboseFlag) {
}
}
}
/**
* Throws a RuntimeException with a message describing the error.
*/
throw new RuntimeException(message);
}
/**
* Inner class used to represent a loader of resources and classes
* from a base URL. Somewhat modified version of code in
* sun.misc.URLClassPath.JarLoader
*/
private static class JarLoader {
/*
* Creates a new Loader for the specified URL.
*/
try {
} catch (MalformedURLException e) {
} catch (IOException e) {
}
base = tmpBaseURL;
}
/*
* Returns the base URL for this Loader.
*/
return base;
}
return jar;
}
// Optimize case where url refers to a local jar file
throw new FileNotFoundException(path);
}
}
//uc.setRequestProperty(USER_AGENT_JAVA_VERSION, JAVA_VERSION);
}
/*
* Returns the JAR file local class path, or null if none.
*/
}
}
}
return null;
}
/*
* Parses value of the Class-Path manifest attribute and returns
* an array of URLs relative to the specified base URL.
*/
throws MalformedURLException
{
int i = 0;
while (st.hasMoreTokens()) {
i++;
}
return urls;
}
}
}