[SCM] jigsaw packaging branch, master, updated. 5e0769ad66a55d12e62fab944c003748ac58cee6

Guillaume Mazoyer gmazoyer-guest at alioth.debian.org
Wed Aug 24 14:56:36 UTC 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "jigsaw packaging".

The branch, master has been updated
       via  5e0769ad66a55d12e62fab944c003748ac58cee6 (commit)
      from  1b36941265cbcf03aadb203be99765bfc8990641 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 5e0769ad66a55d12e62fab944c003748ac58cee6
Author: Guillaume Mazoyer <respawneral at gmail.com>
Date:   Wed Aug 24 16:56:08 2011 +0200

    Keep Alan Bateman patch as Debian patch.

-----------------------------------------------------------------------

Summary of changes:
 debian-wip/patches/06_alanb_mp_prototype.patch     |  400 ++++++++++++++++++++
 debian-wip/patches/series                          |    1 +
 jdk/src/share/bin/java.c                           |   22 --
 .../classes/org/openjdk/jigsaw/ClassInfo.java      |    7 -
 .../share/classes/org/openjdk/jigsaw/Launcher.java |   31 +--
 5 files changed, 409 insertions(+), 52 deletions(-)

diff --git a/debian-wip/patches/06_alanb_mp_prototype.patch b/debian-wip/patches/06_alanb_mp_prototype.patch
new file mode 100644
index 0000000..a4ecb7d
--- /dev/null
+++ b/debian-wip/patches/06_alanb_mp_prototype.patch
@@ -0,0 +1,400 @@
+## Description: Exploded modules and modules path.
+## Origin/Author: Alan Batemane
+## Bug: bug URL
+Index: jigsaw-1.8/jdk/src/share/bin/java.c
+===================================================================
+--- jigsaw-1.8.orig/jdk/src/share/bin/java.c	2011-08-24 15:55:11.807369204 +0200
++++ jigsaw-1.8/jdk/src/share/bin/java.c	2011-08-24 15:54:39.391208459 +0200
+@@ -768,6 +768,22 @@
+         JLI_MemFree((char *) s);
+ }
+ 
++static void
++SetModulePath(const char *s)
++{
++    char *def;
++    size_t len;
++    const char *orig = s;
++    static const char format[] = "-Djava.module.path=%s";
++    len = sizeof(format) - 2 + JLI_StrLen(s); /* -2 == strlen("%s") */
++    def = JLI_MemAlloc(len);
++    JLI_Snprintf(def, len, format, s);
++    AddOption(def, NULL);
++    if (s != orig)
++        JLI_MemFree((char *) s);
++}
++
++
+ /*
+  * Set the bootclasspath for installed modules.
+  * A temporary workaround until jigsaw legacy support is
+@@ -1101,6 +1117,12 @@
+             /* -classpath can only be set when running legacy mode */
+             mode = LM_CLASS;
+             argv++; --argc;
++        } else if (JLI_StrCmp(arg, "-modulepath") == 0 || JLI_StrCmp(arg, "-mp") == 0) {
++            ARG_CHECK (argc, ARG_ERROR1, arg);
++            SetModulePath(*argv);
++            /* -modulepath can only be set when running in module mode */
++            mode = LM_MODULE;
++            argv++; --argc;
+         } else if (JLI_StrCmp(arg, "-jar") == 0) {
+             ARG_CHECK (argc, ARG_ERROR2, arg);
+             if (mode == LM_MODULE)
+Index: jigsaw-1.8/jdk/src/share/classes/org/openjdk/jigsaw/ClassInfo.java
+===================================================================
+--- jigsaw-1.8.orig/jdk/src/share/classes/org/openjdk/jigsaw/ClassInfo.java	2011-08-24 15:55:51.263564859 +0200
++++ jigsaw-1.8/jdk/src/share/classes/org/openjdk/jigsaw/ClassInfo.java	2011-08-24 15:54:39.391208459 +0200
+@@ -363,6 +363,13 @@
+         }
+         return ci;
+     }
++    
++    static ClassInfo parse(byte[] buf) throws IOException {
++        ClassInfo ci = new ClassInfo();
++        ci.load(ByteBuffer.wrap(buf, 0, buf.length), /*path*/null);
++        return ci;
++    }
++    
+ 
+     // ## Test
+     //
+Index: jigsaw-1.8/jdk/src/share/classes/org/openjdk/jigsaw/Launcher.java
+===================================================================
+--- jigsaw-1.8.orig/jdk/src/share/classes/org/openjdk/jigsaw/Launcher.java	2011-08-24 15:55:51.595566505 +0200
++++ jigsaw-1.8/jdk/src/share/classes/org/openjdk/jigsaw/Launcher.java	2011-08-24 15:54:39.395208479 +0200
+@@ -27,9 +27,6 @@
+ 
+ import java.io.*;
+ import java.lang.module.*;
+-import java.lang.reflect.*;
+-
+-import static org.openjdk.jigsaw.Trace.*;
+ 
+ 
+ public final class Launcher {
+@@ -43,8 +40,13 @@
+     private static Loader loadModule(File libPath, ModuleIdQuery midq)
+         throws IOException
+     {
+-
+         Library lb = SimpleLibrary.open(libPath, false);
++        
++        // interpose modulepath library if -modulepath set
++        String mp = System.getProperty("java.module.path");
++        if (mp != null)
++            lb = ModulePathLibrary.open(mp, lb);
++        
+         ModuleId mid = lb.findLatestModuleId(midq);
+         if (mid == null)
+             throw new Error(midq + ": No installed module"
+@@ -56,16 +58,29 @@
+         if (cn == null)
+             throw new Error(mid + ": Module does not specify"
+                             + " a main class");
++        
+         Configuration<Context> cf = lb.readConfiguration(mid);
+-        if (cf == null)
+-            throw new Error(mid + ": Module not configured");
++        if (cf == null) {
++            // module not configured so if running with -modulepath we compute
++            // the full configuration for the root module
++            if ((lb instanceof ModulePathLibrary)) {
++                try {
++                    cf = Configurator.configure(lb, mi.id().toQuery());
++                } catch (ConfigurationException ce) {
++                    throw new Error(mid + ": Module cannot be configured", ce);
++                }        
++            } else {
++                throw new Error(mid + ": Module not configured");
++            }
++        }
++
+         Context cx = cf.getContextForModuleName(mid.name());
+         if (cx == null)
+             throw new InternalError(mid + ": Cannot find context");
+         LoaderPool lp = new LoaderPool(lb, cf, cn);
+ 
+         return lp.findLoader(cx);
+-
++        
+     }
+ 
+     public static ClassLoader launch(String midqs) {
+@@ -115,5 +130,5 @@
+     public static String mainClass(ClassLoader cl) {
+         return ((Loader)cl).pool.mainClass();
+     }
+-
++    
+ }
+Index: jigsaw-1.8/jdk/src/share/classes/org/openjdk/jigsaw/ModulePathLibrary.java
+===================================================================
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ jigsaw-1.8/jdk/src/share/classes/org/openjdk/jigsaw/ModulePathLibrary.java	2011-08-24 15:54:39.395208479 +0200
+@@ -0,0 +1,265 @@
++/*
++ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * 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.
++ */
++
++package org.openjdk.jigsaw;
++
++import java.lang.module.*;
++import java.util.*;
++import java.net.URI;
++import java.nio.file.Files;
++import java.nio.file.*;
++import java.nio.file.attribute.BasicFileAttributes;
++import java.io.*;
++import java.security.CodeSigner;
++import java.security.SignatureException;
++
++/**
++ * A simple read-only module library based on a module path as specified by the
++ * -modulepath (-mp) option.
++ */
++
++public final class ModulePathLibrary
++    extends Library
++{
++    private static final JigsawModuleSystem jms = JigsawModuleSystem.instance();
++    
++    private final Path root;
++    private final Library parent;
++    
++    // mid -> module-info bytes
++    private final Map<ModuleId,byte[]> modules;
++    
++    private ModulePathLibrary(String path, Library parent) throws IOException {
++        this.root = FileSystems.getDefault().getPath(path);
++        this.parent = parent;
++        this.modules = new HashMap<>();
++        
++        // preload module info for each module
++        try (DirectoryStream<Path> stream = Files.newDirectoryStream(root)) {
++            for (Path name: stream) {
++                Path mipath = name.resolve("module-info.class");
++                if (Files.exists(mipath)) { 
++                    byte[] bytes = Files.readAllBytes(mipath);        
++                    ClassInfo ci = ClassInfo.parse(bytes);
++                    ModuleId mid = jms.parseModuleId(name.getFileName().toString(), 
++                                                     ci.moduleVersion());
++                    modules.put(mid, bytes);
++                }
++            }
++        }
++    }
++    
++    static ModulePathLibrary open(String path, Library parent) throws IOException {
++        return new ModulePathLibrary(path, parent);
++    }
++    
++    @Override
++    public String name() {
++        return root.toString();
++    }
++
++    @Override
++    public Library parent() {
++        return parent;
++    }
++    
++    @Override
++    public URI location() {
++        return root.toUri();
++    }    
++    
++    @Override
++    public int majorVersion() {
++        return 1;
++    }
++    
++    @Override
++    public int minorVersion() {
++        return 0;
++    }
++    
++    @Override
++    public byte[] readLocalModuleInfoBytes(ModuleId mid) {
++        return modules.get(mid);
++    }
++    
++    @Override
++    public void gatherLocalModuleIds(String moduleName, Set<ModuleId> mids) {
++        if (moduleName == null) {
++            mids.addAll(modules.keySet());
++        } else {
++            for (ModuleId mid: modules.keySet()) {
++                if (mid.name().equals(moduleName))
++                    mids.add(mid);
++            }
++        }
++    }
++    
++    @Override
++    public byte[] readLocalClass(ModuleId mid, String className)
++        throws IOException
++    {
++        String sep = root.getFileSystem().getSeparator();
++        assert sep.length() == 1;
++        String fn = className.replace('.', sep.charAt(0)) + ".class";
++        Path file = root.resolve(mid.name()).resolve(fn);
++        return Files.readAllBytes(file);
++    }
++
++    @Override
++    public List<String> listLocalClasses(ModuleId mid, final boolean all)
++        throws IOException
++    {        
++        final Path top = root.resolve(mid.name());
++        final List<String> result = new LinkedList<>();
++        Files.walkFileTree(top, new SimpleFileVisitor<Path>() {
++            @Override
++            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) 
++                throws IOException
++            {
++                String fn = file.getFileName().toString();
++                if (fn.endsWith(".class") && !fn.equals("module-info.class")) {
++                    ClassInfo ci = ClassInfo.read(file.toFile());
++                    if (all || ci.isPublic()) {
++                        // modules/foo/org/Foo.class => org.Foo
++                        String cn = top.relativize(file).toString();
++                        String sep = root.getFileSystem().getSeparator();
++                        cn = cn.replace(sep.charAt(0), '.');
++                        int len = cn.length() - 6;
++                        cn = cn.substring(0, len);
++                        result.add(cn);
++                    }
++                }
++                return FileVisitResult.CONTINUE;
++            }
++        });
++        return result;
++    }
++    
++    @Override
++    public byte[] readModuleInfoBytes(ModuleId mid)
++        throws IOException
++    {
++        byte[] bytes = modules.get(mid);
++        return (bytes != null) ? bytes : parent.readModuleInfoBytes(mid);
++    }    
++
++    @Override
++    public Configuration<Context> readConfiguration(ModuleId mid)
++        throws IOException
++    {
++        // configuration not stored
++        return null;
++    }            
++
++    @Override
++    public void installFromManifests(Collection<Manifest> mfs)
++        throws ConfigurationException, IOException
++    {
++        throw new UnsupportedOperationException("Can't install into module path");
++    }             
++
++    @Override
++    public void install(Collection<File> mfs, boolean verifySignature)
++        throws ConfigurationException, IOException, SignatureException
++    {
++        throw new UnsupportedOperationException("Can't install into module path");
++    }            
++
++    @Override
++    public Resolution resolve(Collection<ModuleIdQuery> midqs)
++        throws ConfigurationException, IOException
++    {
++        // only required when installing
++        throw new RuntimeException("not implemented");
++    }
++
++    @Override
++    public void install(Resolution res, boolean verifySignature)
++        throws ConfigurationException, IOException, SignatureException
++    {
++        throw new UnsupportedOperationException("Can't install into module path");
++    }            
++
++    @Override
++    public URI findLocalResource(ModuleId mid, String rn)
++        throws IOException
++    {
++        // resources be in a module path?
++        return null;
++    }            
++
++    @Override
++    public File findLocalNativeLibrary(ModuleId mid, String name)
++        throws IOException
++    {
++        // no native libraries in a module path
++        return null;
++    }            
++
++    @Override
++    public File classPath(ModuleId mid)
++        throws IOException
++    {
++        Path dir = root.resolve(mid.name());
++        return dir.toFile();
++    }
++    
++    private static class EmptyRepositoryList implements RemoteRepositoryList {
++        @Override
++        public List<RemoteRepository> repositories() throws IOException {
++            return Collections.emptyList();
++        }
++        @Override
++        public RemoteRepository firstRepository() throws IOException {
++            return null;
++        }
++        public RemoteRepository add(URI uri, int position) throws IOException {
++            throw new RuntimeException();
++        }
++        public boolean remove(RemoteRepository rr) throws IOException {
++            throw new RuntimeException();
++        }
++        public boolean areCatalogsStale() throws IOException {
++            throw new RuntimeException();
++        }
++        public boolean updateCatalogs(boolean force) throws IOException {
++            throw new RuntimeException();
++        }
++    }
++
++    @Override
++    public RemoteRepositoryList repositoryList() throws IOException {
++        return new EmptyRepositoryList();
++    }
++            
++    @Override
++    public CodeSigner[] readLocalCodeSigners(ModuleId mid)
++        throws IOException
++    {        
++        // classes in a module path are not signed
++        return null;
++    }
++}
diff --git a/debian-wip/patches/series b/debian-wip/patches/series
index 2c0d4a7..37d258a 100644
--- a/debian-wip/patches/series
+++ b/debian-wip/patches/series
@@ -3,3 +3,4 @@
 03_hosts_tests.patch
 04_junit_jar.patch
 05_disable_tests.patch
+06_alanb_mp_prototype.patch
diff --git a/jdk/src/share/bin/java.c b/jdk/src/share/bin/java.c
index 12c323a..16d6f69 100644
--- a/jdk/src/share/bin/java.c
+++ b/jdk/src/share/bin/java.c
@@ -768,22 +768,6 @@ SetClassPath(const char *s)
         JLI_MemFree((char *) s);
 }
 
-static void
-SetModulePath(const char *s)
-{
-    char *def;
-    size_t len;
-    const char *orig = s;
-    static const char format[] = "-Djava.module.path=%s";
-    len = sizeof(format) - 2 + JLI_StrLen(s); /* -2 == strlen("%s") */
-    def = JLI_MemAlloc(len);
-    JLI_Snprintf(def, len, format, s);
-    AddOption(def, NULL);
-    if (s != orig)
-        JLI_MemFree((char *) s);
-}
-
-
 /*
  * Set the bootclasspath for installed modules.
  * A temporary workaround until jigsaw legacy support is
@@ -1117,12 +1101,6 @@ ParseArguments(int *pargc, char ***pargv,
             /* -classpath can only be set when running legacy mode */
             mode = LM_CLASS;
             argv++; --argc;
-        } else if (JLI_StrCmp(arg, "-modulepath") == 0 || JLI_StrCmp(arg, "-mp") == 0) {
-            ARG_CHECK (argc, ARG_ERROR1, arg);
-            SetModulePath(*argv);
-            /* -modulepath can only be set when running in module mode */
-            mode = LM_MODULE;
-            argv++; --argc;
         } else if (JLI_StrCmp(arg, "-jar") == 0) {
             ARG_CHECK (argc, ARG_ERROR2, arg);
             if (mode == LM_MODULE)
diff --git a/jdk/src/share/classes/org/openjdk/jigsaw/ClassInfo.java b/jdk/src/share/classes/org/openjdk/jigsaw/ClassInfo.java
index 8b0ba4d..1493d67 100644
--- a/jdk/src/share/classes/org/openjdk/jigsaw/ClassInfo.java
+++ b/jdk/src/share/classes/org/openjdk/jigsaw/ClassInfo.java
@@ -363,13 +363,6 @@ public class ClassInfo {
         }
         return ci;
     }
-    
-    static ClassInfo parse(byte[] buf) throws IOException {
-        ClassInfo ci = new ClassInfo();
-        ci.load(ByteBuffer.wrap(buf, 0, buf.length), /*path*/null);
-        return ci;
-    }
-    
 
     // ## Test
     //
diff --git a/jdk/src/share/classes/org/openjdk/jigsaw/Launcher.java b/jdk/src/share/classes/org/openjdk/jigsaw/Launcher.java
index 2788001..20f7797 100644
--- a/jdk/src/share/classes/org/openjdk/jigsaw/Launcher.java
+++ b/jdk/src/share/classes/org/openjdk/jigsaw/Launcher.java
@@ -27,6 +27,9 @@ package org.openjdk.jigsaw;
 
 import java.io.*;
 import java.lang.module.*;
+import java.lang.reflect.*;
+
+import static org.openjdk.jigsaw.Trace.*;
 
 
 public final class Launcher {
@@ -40,13 +43,8 @@ public final class Launcher {
     private static Loader loadModule(File libPath, ModuleIdQuery midq)
         throws IOException
     {
+
         Library lb = SimpleLibrary.open(libPath, false);
-        
-        // interpose modulepath library if -modulepath set
-        String mp = System.getProperty("java.module.path");
-        if (mp != null)
-            lb = ModulePathLibrary.open(mp, lb);
-        
         ModuleId mid = lb.findLatestModuleId(midq);
         if (mid == null)
             throw new Error(midq + ": No installed module"
@@ -58,29 +56,16 @@ public final class Launcher {
         if (cn == null)
             throw new Error(mid + ": Module does not specify"
                             + " a main class");
-        
         Configuration<Context> cf = lb.readConfiguration(mid);
-        if (cf == null) {
-            // module not configured so if running with -modulepath we compute
-            // the full configuration for the root module
-            if ((lb instanceof ModulePathLibrary)) {
-                try {
-                    cf = Configurator.configure(lb, mi.id().toQuery());
-                } catch (ConfigurationException ce) {
-                    throw new Error(mid + ": Module cannot be configured", ce);
-                }        
-            } else {
-                throw new Error(mid + ": Module not configured");
-            }
-        }
-
+        if (cf == null)
+            throw new Error(mid + ": Module not configured");
         Context cx = cf.getContextForModuleName(mid.name());
         if (cx == null)
             throw new InternalError(mid + ": Cannot find context");
         LoaderPool lp = new LoaderPool(lb, cf, cn);
 
         return lp.findLoader(cx);
-        
+
     }
 
     public static ClassLoader launch(String midqs) {
@@ -130,5 +115,5 @@ public final class Launcher {
     public static String mainClass(ClassLoader cl) {
         return ((Loader)cl).pool.mainClass();
     }
-    
+
 }


hooks/post-receive
-- 
jigsaw packaging



More information about the pkg-java-commits mailing list