Return-Path: Delivered-To: apmail-harmony-dev-archive@www.apache.org Received: (qmail 4243 invoked from network); 15 Jun 2009 15:36:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 15 Jun 2009 15:36:39 -0000 Received: (qmail 97308 invoked by uid 500); 15 Jun 2009 15:36:50 -0000 Delivered-To: apmail-harmony-dev-archive@harmony.apache.org Received: (qmail 97229 invoked by uid 500); 15 Jun 2009 15:36:49 -0000 Mailing-List: contact dev-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list dev@harmony.apache.org Received: (qmail 97218 invoked by uid 99); 15 Jun 2009 15:36:49 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Jun 2009 15:36:49 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of oliver.deakin@googlemail.com designates 209.85.218.211 as permitted sender) Received: from [209.85.218.211] (HELO mail-bw0-f211.google.com) (209.85.218.211) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Jun 2009 15:36:39 +0000 Received: by bwz7 with SMTP id 7so3423961bwz.36 for ; Mon, 15 Jun 2009 08:36:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=HFSeI1TdXL9MCCPcqRnYvWM5hqbNO9Q0ePWpEzKXbEk=; b=nNtRwChYjwzIgWZFDBLDyjC+PBgoeE/NVXN+VW3yIeLRe54Ux6lhWrQ0Zfo0LPM7Ro kFPJuM/aWKm8tRzbBj0ULUbT7eaQdmJ67FihgA22sMYKo+eEblbR5iM1X43AHcD6hP2I 5vF7IsGemkY0Vd2JZhkCbS1o6jeMhY7VKuPfA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=R1cHpvRklMgojElUaNXAj0o6S+ynGxtWcI6bob+8k68VqGtkIt23+JdzztJiKJ6Z7Q ZQtbwux/aB8V/tNY9EAklq+C06pWI+GXacGzhnO/h+iSbujbKBL68kKauVwHS9jWmDfT q+mx1YQLheU2C3z3XAx61L7JCm7HeTBxtlm9g= Received: by 10.204.60.148 with SMTP id p20mr7136663bkh.160.1245080177530; Mon, 15 Jun 2009 08:36:17 -0700 (PDT) Received: from ?9.20.183.162? (blueice4n2.uk.ibm.com [195.212.29.92]) by mx.google.com with ESMTPS id 22sm8060305fkr.0.2009.06.15.08.36.14 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 15 Jun 2009 08:36:15 -0700 (PDT) Message-ID: <4A366A6D.8020907@googlemail.com> Date: Mon, 15 Jun 2009 16:36:13 +0100 From: Oliver Deakin User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-Version: 1.0 To: dev@harmony.apache.org Subject: Re: svn commit: r784747 - in /harmony/enhanced/classlib/trunk/modules/luni/src/main: java/org/apache/harmony/luni/util/Version.java native/launcher/shared/main.c References: <20090615121414.131CD238889B@eris.apache.org> In-Reply-To: <20090615121414.131CD238889B@eris.apache.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Thanks Mark - just back from holiday now and catching up on mail. I've just committed (r784811) a further patch so -version gives us the correct copyright and revision number info. It also moves the handling of -showversion (and -showversion:extended) to the Version class. You should now see: >java -version Apache Harmony Launcher : (c) Copyright 1991, 2009 The Apache Software Foundation or its licensors, as applicable. java version "1.5.0" Apache Harmony (1.5.0) DRLVM (11.2.0) pre-alpha : not complete or compatible svn = r784759, (Jun 15 2009), Windows/ia32/msvc 1310, release build http://harmony.apache.org >java -showversion HelloWorld Apache Harmony Launcher : (c) Copyright 1991, 2009 The Apache Software Foundation or its licensors, as applicable. java version "1.5.0" Apache Harmony (1.5.0) DRLVM (11.2.0) pre-alpha : not complete or compatible svn = r784759, (Jun 15 2009), Windows/ia32/msvc 1310, release build http://harmony.apache.org Hello World! which I think looks about right, if a little verbose. The :extended option gives the full classlib module breakdowns, and works with both -version and -showversion. What do you think? Regards, Oliver hindessm@apache.org wrote: > Author: hindessm > Date: Mon Jun 15 12:14:13 2009 > New Revision: 784747 > > URL: http://svn.apache.org/viewvc?rev=784747&view=rev > Log: > Reverting r782693 - which reverted r763589 - which was: > > Commit Version class to handle -version command line option in a uniform > way across VMs (as discussed on the dev list). > > Added: > harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/Version.java (with props) > Modified: > harmony/enhanced/classlib/trunk/modules/luni/src/main/native/launcher/shared/main.c > > Added: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/Version.java > URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/Version.java?rev=784747&view=auto > ============================================================================== > --- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/Version.java (added) > +++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/Version.java Mon Jun 15 12:14:13 2009 > @@ -0,0 +1,103 @@ > +/* > + * Licensed to the Apache Software Foundation (ASF) under one or more > + * contributor license agreements. See the NOTICE file distributed with > + * this work for additional information regarding copyright ownership. > + * The ASF licenses this file to You under the Apache License, Version 2.0 > + * (the "License"); you may not use this file except in compliance with > + * the License. You may obtain a copy of the License at > + * > + * http://www.apache.org/licenses/LICENSE-2.0 > + * > + * Unless required by applicable law or agreed to in writing, software > + * distributed under the License is distributed on an "AS IS" BASIS, > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. > + * See the License for the specific language governing permissions and > + * limitations under the License. > + */ > + > +package org.apache.harmony.luni.util; > + > +import java.util.StringTokenizer; > +import java.util.Iterator; > +import java.util.jar.*; > +import java.io.IOException; > + > +class Version { > + /* > + * Display VM and runtime version information > + */ > + private static void displayVMVersion() { > + String version = System.getProperty("java.version"); > + if (version != null) System.out.println("java version \"" + version + "\""); > + > + String name = System.getProperty("java.runtime.name"); > + version = System.getProperty("java.runtime.version"); > + > + if (name != null) { > + if (version != null) name = name + " (" + version + ")"; > + System.out.println(name); > + } > + > + name = System.getProperty("java.vm.name"); > + version = System.getProperty("java.vm.version"); > + if (name != null) { > + if (version != null) name = name + " (" + version + ")"; > + System.out.println(name); > + } > + > + name = System.getProperty("java.fullversion"); > + if (name != null) System.out.println(name); > + } > + > + /* > + * Display extended class library version information > + */ > + private static void displayClasslibVersion() { > + // Get the bootclasspath and tokenise for each jar file > + String bootclasspath = System.getProperty("org.apache.harmony.boot.class.path"); > + if (bootclasspath == null) return; > + > + StringTokenizer tokenizer = new StringTokenizer(bootclasspath, System.getProperty("path.separator")); > + > + while (tokenizer.hasMoreTokens()) { > + String jarPath = tokenizer.nextToken(); > + > + // If the current path is not a jar file, then continue iteration through tokens > + if (!jarPath.endsWith(".jar")) continue; > + > + // Get the jar manifest and find it's name and version info > + JarFile jarFile; > + Manifest manifest; > + try { > + jarFile = new JarFile(jarPath); > + manifest = jarFile.getManifest(); > + } catch (IOException e) { > + // We have hit an exception - just carry onto the next jar file > + continue; > + } > + > + // Get the manifest attributes and output those we are interested in > + Attributes attributes = manifest.getMainAttributes(); > + if (attributes == null) continue; > + > + String bundleName = attributes.getValue("Bundle-Name"); > + if (bundleName == null) continue; > + String bundleVersion = attributes.getValue("Bundle-Version"); > + if (bundleVersion == null) continue; > + > + System.out.println(jarPath + " " + bundleName + " " + bundleVersion); > + } > + > + } > + > + public static void version(String versionOpt) { > + if (versionOpt.equals("-version")) { > + displayVMVersion(); > + } else if (versionOpt.equals("-version:extended")) { > + displayVMVersion(); > + displayClasslibVersion(); > + } else { > + System.out.println("Option " + versionOpt + " unrecognised - please use -version or -version:extended"); > + } > + } > +} > > Propchange: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/Version.java > ------------------------------------------------------------------------------ > svn:eol-style = native > > Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/native/launcher/shared/main.c > URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/launcher/shared/main.c?rev=784747&r1=784746&r2=784747&view=diff > ============================================================================== > --- harmony/enhanced/classlib/trunk/modules/luni/src/main/native/launcher/shared/main.c (original) > +++ harmony/enhanced/classlib/trunk/modules/luni/src/main/native/launcher/shared/main.c Mon Jun 15 12:14:13 2009 > @@ -58,7 +58,7 @@ > PROTOTYPE ((HyPortLibrary * portLibrary, int argc, char **argv, UDATA handle, > jint version, jboolean ignoreUnrecognized, char *mainClass, > UDATA classArg, char *propertiesFileName, > - int isStandaloneJar, char *vmdllsubdir)); > + int isStandaloneJar, char *vmdllsubdir, int versionFlag)); > static int createVMArgs > PROTOTYPE ((HyPortLibrary * portLibrary, int argc, char **argv, > jint version, jboolean ignoreUnrecognized, > @@ -227,8 +227,9 @@ > /* The arg is a JAR file to run */ > isStandaloneJar = 1; > } > - if (0 == strcmp ("-version", argv[i])) { > - versionFlag = 1; > + if (0 == strncmp ("-version", argv[i], 8)) { > + /* Display version information */ > + versionFlag = i; > } > if (0 == strcmp ("-showversion", argv[i])) { > /* We are being asked to print our version and continue */ > @@ -363,12 +364,6 @@ > } > } > > - if (versionFlag == 1) { > - /* > - * We are being asked to print our version, and quit > - */ > - hyfile_printf (PORTLIB, HYPORT_TTY_OUT, HY_COPYRIGHT_STRING "\n"); > - } > /* set up the properties file */ > propertiesFileName = hymem_allocate_memory (strlen (vmiPath) + 12); > if (propertiesFileName == NULL) > @@ -392,7 +387,7 @@ > /* main launcher processing in this function */ > rc = invocation > (PORTLIB, argc, argv, handle, JNI_VERSION_1_4, JNI_TRUE, mainClass, > - classArg, propertiesFileName, isStandaloneJar, vmdllsubdir); > + classArg, propertiesFileName, isStandaloneJar, vmdllsubdir, versionFlag); > if (rc) > { > /* Print an error message except in the case where an uncaught Exception > @@ -642,7 +637,7 @@ > invocation (HyPortLibrary * portLibrary, int argc, char **argv, UDATA handle, > jint version, jboolean ignoreUnrecognized, char *mainClass, > UDATA classArg, char *propertiesFileName, > - int isStandaloneJar, char *vmdllsubdir) > + int isStandaloneJar, char *vmdllsubdir, int versionFlag) > { > JavaVMInitArgs vm_args; > JavaVM *jvm; > @@ -678,6 +673,27 @@ > } > > rc = 0; > + > + if (versionFlag) { > + jclass clazz; > + jmethodID mID; > + jstring jStrObject; > + > + jStrObject = (*env)->NewStringUTF (env, argv[versionFlag]); > + if (!jStrObject) return 3; > + > + clazz = (*env)->FindClass (env, "org/apache/harmony/luni/util/Version"); > + if (!clazz) return 3; > + > + mID = (*env)->GetStaticMethodID (env, clazz, "version", > + "(Ljava/lang/String;)V"); > + if (!mID) return 3; > + > + (*env)->CallStaticVoidMethod(env, clazz, mID, jStrObject); > + > + return 0; > + } > + > if (mainClass) > { > if (isStandaloneJar) > @@ -952,7 +968,8 @@ > { > if ( (strcmp (argv[i], "-jar") != 0) > && (strncmp (argv[i], "-vmdir:", 7) != 0) > - && (strncmp (argv[i], "-vm:", 4) != 0) ) > + && (strncmp (argv[i], "-vm:", 4) != 0) > + && (strncmp (argv[i], "-version", 8) != 0)) > { > /* special coding for -classpath and -cp */ > /* they get passed to the vm as -Djava.class.path */ > > > > -- Oliver Deakin Unless stated otherwise above: IBM United Kingdom Limited - Registered in England and Wales with number 741598. Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU