Skip to main content

Better identification of Framework jars is needed (was: svn commit: r688 - trunk/code: build src/share/classes/com/sun/tck/j2me src/share/lib)

1 reply [Last post]
Anonymous

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Alexander Alexeev

Hi Vladimir,

very cool and long-awaited feature! I've one thought about it. May be we should
provide the initial (build time) list of jar's files with checksums in
addition. Then the output will be something like:
applet_agent.jar Checksum: rSYOniVGOS7uF7ZjIA5dQVzM1rM=
cdc_agent.jar Checksum: tDaeZLgU6tDIybhJTY5PjofrHcs= Diffs!!!
Initial: D1QQCbFR4rKhHYpi1ZLPjgvp5ao=
cdc_messaging.jar Checksum: aiklxYVHrHyESs8RZGRFh8bV8WY=
cldc_agent.jar Missed!!!
cldc_commClient.jar Checksum: 8UHhf0XbYW7mlC5y8ZUOy43xT9s=

Thanks,
Alexander

vsizikov@dev.java.net wrote:
> Author: vsizikov
> Date: 2007-04-17 22:54:26+0000
> New Revision: 688
>
> Modified:
> trunk/code/build/build.properties
> trunk/code/build/build.xml
> trunk/code/build/common-tasks.xml
> trunk/code/src/share/classes/com/sun/tck/j2me/J2meTckFrameworkInfo.java
> trunk/code/src/share/classes/com/sun/tck/j2me/framework.properties
> trunk/code/src/share/lib/framework_version.txt
>
> Log:
> Fixed ISSUE #97: Better identification of Framework jars is needed.
>
> Contributor: Vladimir Sizikov
> Reviewer: Mikhail Gorshenev
>
> Build is OK.
>
> Modified: trunk/code/build/build.properties
> Url: https://cqme.dev.java.net/source/browse/cqme/trunk/code/build/build.prop...
> ==============================================================================
> --- trunk/code/build/build.properties (original)
> +++ trunk/code/build/build.properties 2007-04-17 22:54:26+0000
> @@ -40,7 +40,7 @@
> VERSION = 12
> VERSION_LONG = 1.2
> PRODUCT = j2me-tck-framework
> -PRODUCT_LONG = Java ME TCK Framework
> +PRODUCT_LONG = ME Framework
>
> # Javadoc properties
> J2SE_API_URL=http://java.sun.com/j2se/1.4.2/docs/api/
>
> Modified: trunk/code/build/build.xml
> Url: https://cqme.dev.java.net/source/browse/cqme/trunk/code/build/build.xml?...
> ==============================================================================
> --- trunk/code/build/build.xml (original)
> +++ trunk/code/build/build.xml 2007-04-17 22:54:26+0000
> @@ -69,6 +69,16 @@
>
>

>
> +
> +
> +
> + property="BUILD_DATE"
> + pattern="d MMM yyyy HH:mm:ss Z"
> + locale="en,US"/>
> +

> +
> +
> +
>
>

>
> @@ -82,7 +92,7 @@
>
>
>

> -
> +
>

>
> @@ -274,6 +284,8 @@
>
>
>
> +
> +
>

>
>
>
> Modified: trunk/code/build/common-tasks.xml
> Url: https://cqme.dev.java.net/source/browse/cqme/trunk/code/build/common-tas...
> ==============================================================================
> --- trunk/code/build/common-tasks.xml (original)
> +++ trunk/code/build/common-tasks.xml 2007-04-17 22:54:26+0000
> @@ -120,6 +120,8 @@
>
>
>
> +
> +
>

>
>
>
> Modified: trunk/code/src/share/classes/com/sun/tck/j2me/J2meTckFrameworkInfo.java
> Url: https://cqme.dev.java.net/source/browse/cqme/trunk/code/src/share/classe...
> ==============================================================================
> --- trunk/code/src/share/classes/com/sun/tck/j2me/J2meTckFrameworkInfo.java (original)
> +++ trunk/code/src/share/classes/com/sun/tck/j2me/J2meTckFrameworkInfo.java 2007-04-17 22:54:26+0000
> @@ -27,9 +27,15 @@
>
> package com.sun.tck.j2me;
>
> +import java.io.FileInputStream;
> +import java.io.FileNotFoundException;
> +import java.io.FilenameFilter;
> import java.io.IOException;
> import java.io.InputStream;
> import java.io.File;
> +import java.security.DigestInputStream;
> +import java.security.MessageDigest;
> +import java.security.NoSuchAlgorithmException;
> import java.util.Properties;
>
> /**
> @@ -38,11 +44,19 @@
> */
> public final class J2meTckFrameworkInfo {
> private static Properties props = loadProps();
> -
> +
> private static File libDir;
>
> private static final String J2ME_FW_JAR = "j2mefw_jt.jar";
>
> + // TODO: Eliminate dependency on non-public API, will be done
> + // as soon as we integrate Base64 encoder into repository,
> + // from PhoneMe project.
> + private static final sun.misc.BASE64Encoder BASE64_ENCODER
> + = new sun.misc.BASE64Encoder();
> +
> +private static final byte[] BUFFER = new byte[32 * 1024];
> +
> private J2meTckFrameworkInfo() {
> // empty private constructor
> }
> @@ -56,6 +70,68 @@
> public static void main(String[] args) {
> System.out.println("Name: " + getName());
> System.out.println("Version: " + getVersion());
> + System.out.println(
> + "Build Date: " + props.getProperty("framework.date"));
> + System.out.println();
> + try {
> + System.out.println("Install Dir: "
> + + getFrameworkLibDir().getCanonicalPath());
> + } catch (IOException ignore) {
> + // ignore
> + }
> + System.out.println();
> + listAvailableJarFiles();
> + }
> +
> + // lists all present in the Framework directory JAR files,
> + // and their checksums (SHA-1 digests, Base64 encoded)
> + private static void listAvailableJarFiles() {
> + File baseDir = getFrameworkLibDir();
> + File[] jarFiles = baseDir.listFiles(new FilenameFilter() {
> + public boolean accept(File dir, String name) {
> + return name.endsWith(".jar") || name.endsWith(".JAR");
> + }
> + });
> +
> + if (jarFiles != null && jarFiles.length > 0) {
> + System.out.println(
> + "Available JAR files (" + jarFiles.length + " total):");
> + for (File file : jarFiles) {
> + System.out.printf(" %1$-35s Checksum: %2$s",
> + file.getName(), calculateDigest(file));
> + System.out.println();
> + }
> + }
> + }
> +
> + // might return null if the digest cannot be calculated for any reason
> + private static String calculateDigest(File file) {
> + String digest = null;
> + InputStream fileContent = null;
> + try {
> + MessageDigest shaDigest = MessageDigest.getInstance("SHA-1");
> + fileContent = new DigestInputStream(
> + new FileInputStream(file), shaDigest);
> + while (fileContent.read(BUFFER) != -1) {
> + // do nothing
> + }
> + digest = BASE64_ENCODER.encode(shaDigest.digest());
> + } catch (NoSuchAlgorithmException ignore) {
> + // ignore
> + } catch (FileNotFoundException e) {
> + // ignore
> + } catch (IOException e) {
> + // ignore
> + } finally {
> + if (fileContent != null) {
> + try {
> + fileContent.close();
> + } catch (IOException ignore) {
> + // ignore
> + }
> + }
> + }
> + return digest;
> }
>
> /**
>
> Modified: trunk/code/src/share/classes/com/sun/tck/j2me/framework.properties
> Url: https://cqme.dev.java.net/source/browse/cqme/trunk/code/src/share/classe...
> ==============================================================================
> --- trunk/code/src/share/classes/com/sun/tck/j2me/framework.properties (original)
> +++ trunk/code/src/share/classes/com/sun/tck/j2me/framework.properties 2007-04-17 22:54:26+0000
> @@ -25,4 +25,5 @@
> #
>
> framework.name=@FRAMEWORK.NAME@
> -framework.version=@FRAMEWORK.VERSION@
> +framework.version=@FRAMEWORK.VERSION@ (@FRAMEWORK.BUILD_ID@ build)
> +framework.date=@FRAMEWORK.BUILD_DATE@
>
> Modified: trunk/code/src/share/lib/framework_version.txt
> Url: https://cqme.dev.java.net/source/browse/cqme/trunk/code/src/share/lib/fr...
> ==============================================================================
> --- trunk/code/src/share/lib/framework_version.txt (original)
> +++ trunk/code/src/share/lib/framework_version.txt 2007-04-17 22:54:26+0000
> @@ -24,4 +24,5 @@
> # information or have any questions.
> #
>
> -Version Info: @PRODUCT@ @VERSION@
> +Version Info: @PRODUCT@ @VERSION@ (@BUILD_ID@ build)
> +Build Date: @BUILD_DATE@
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commits-unsubscribe@cqme.dev.java.net
> For additional commands, e-mail: commits-help@cqme.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: meframework-unsubscribe@cqme.dev.java.net
For additional commands, e-mail: meframework-help@cqme.dev.java.net