src/jdk.zipfs/share/classes/jdk/nio/zipfs/JarFileSystem.java
changeset 48691 554cb38e0caf
parent 48327 d2a837cf9ff1
child 53043 fd2e8f941ded
equal deleted inserted replaced
48690:374c63fbe652 48691:554cb38e0caf
     1 /*
     1 /*
     2  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   107      * then wrap the map in a function that getEntry can use to override root
   107      * then wrap the map in a function that getEntry can use to override root
   108      * entry lookup for entries that have corresponding versioned entries
   108      * entry lookup for entries that have corresponding versioned entries
   109      */
   109      */
   110     private Function<byte[],byte[]> createVersionedLinks(int version) {
   110     private Function<byte[],byte[]> createVersionedLinks(int version) {
   111         HashMap<IndexNode,byte[]> aliasMap = new HashMap<>();
   111         HashMap<IndexNode,byte[]> aliasMap = new HashMap<>();
   112         getVersionMap(version, getInode(getBytes("/META-INF/versions"))).values()
   112         IndexNode verdir = getInode(getBytes("/META-INF/versions"));
       
   113         if (verdir != null) {
       
   114             getVersionMap(version, verdir).values()
   113                 .forEach(versionNode -> {   // for each META-INF/versions/{n} directory
   115                 .forEach(versionNode -> {   // for each META-INF/versions/{n} directory
   114                     // put all the leaf inodes, i.e. entries, into the alias map
   116                     // put all the leaf inodes, i.e. entries, into the alias map
   115                     // possibly shadowing lower versioned entries
   117                     // possibly shadowing lower versioned entries
   116                     walk(versionNode, entryNode -> {
   118                     walk(versionNode, entryNode -> {
   117                         byte[] rootName = getRootName(versionNode, entryNode);
   119                         byte[] rootName = getRootName(versionNode, entryNode);
   122                             }
   124                             }
   123                             aliasMap.put(rootNode, entryNode.name);
   125                             aliasMap.put(rootNode, entryNode.name);
   124                         }
   126                         }
   125                     });
   127                     });
   126                 });
   128                 });
       
   129         }
   127         return path -> aliasMap.get(IndexNode.keyOf(path));
   130         return path -> aliasMap.get(IndexNode.keyOf(path));
   128     }
   131     }
   129 
   132 
   130     /**
   133     /**
   131      * create a sorted version map of version -> inode, for inodes <= max version
   134      * create a sorted version map of version -> inode, for inodes <= max version