jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileStore.java
author sherman
Fri, 15 Apr 2016 13:05:52 -0700
changeset 37365 9cc4eb4d7491
parent 36511 9d0388c6b336
permissions -rw-r--r--
8147460: Clean-up jrtfs implementation Reviewed-by: alanb, jlaskey, sundar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     1
/*
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     4
 *
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    10
 *
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    15
 * accompanied this code).
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    16
 *
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    20
 *
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    23
 * questions.
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    24
 */
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    25
package jdk.internal.jrtfs;
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    26
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    27
import java.io.IOException;
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    28
import java.nio.file.FileStore;
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 27565
diff changeset
    29
import java.nio.file.FileSystem;
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    30
import java.nio.file.attribute.FileAttributeView;
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 27565
diff changeset
    31
import java.nio.file.attribute.BasicFileAttributeView;
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    32
import java.nio.file.attribute.FileStoreAttributeView;
37365
9cc4eb4d7491 8147460: Clean-up jrtfs implementation
sherman
parents: 36511
diff changeset
    33
import java.util.Objects;
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    34
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 27565
diff changeset
    35
/**
9d0388c6b336 8142968: Module System implementation
alanb
parents: 27565
diff changeset
    36
 * File store implementation for jrt file systems.
9d0388c6b336 8142968: Module System implementation
alanb
parents: 27565
diff changeset
    37
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents: 27565
diff changeset
    38
 * @implNote This class needs to maintain JDK 8 source compatibility.
9d0388c6b336 8142968: Module System implementation
alanb
parents: 27565
diff changeset
    39
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents: 27565
diff changeset
    40
 * It is used internally in the JDK to implement jimage/jrtfs access,
9d0388c6b336 8142968: Module System implementation
alanb
parents: 27565
diff changeset
    41
 * but also compiled and delivered as part of the jrtfs.jar to support access
9d0388c6b336 8142968: Module System implementation
alanb
parents: 27565
diff changeset
    42
 * to the jimage file provided by the shipped JDK by tools running on JDK 8.
9d0388c6b336 8142968: Module System implementation
alanb
parents: 27565
diff changeset
    43
 */
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    44
final class JrtFileStore extends FileStore {
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    45
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 27565
diff changeset
    46
    protected final FileSystem jrtfs;
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    47
37365
9cc4eb4d7491 8147460: Clean-up jrtfs implementation
sherman
parents: 36511
diff changeset
    48
    JrtFileStore(JrtPath jrtPath) {
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    49
        this.jrtfs = jrtPath.getFileSystem();
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    50
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    51
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    52
    @Override
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    53
    public String name() {
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    54
        return jrtfs.toString() + "/";
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    55
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    56
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    57
    @Override
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    58
    public String type() {
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    59
        return "jrtfs";
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    60
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    61
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    62
    @Override
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    63
    public boolean isReadOnly() {
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    64
        return jrtfs.isReadOnly();
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    65
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    66
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    67
    @Override
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    68
    public boolean supportsFileAttributeView(String name) {
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    69
        return name.equals("basic") || name.equals("jrt");
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    70
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    71
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    72
    @Override
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    73
    @SuppressWarnings("unchecked")
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    74
    public <V extends FileStoreAttributeView> V getFileStoreAttributeView(Class<V> type) {
37365
9cc4eb4d7491 8147460: Clean-up jrtfs implementation
sherman
parents: 36511
diff changeset
    75
        Objects.requireNonNull(type, "type");
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 27565
diff changeset
    76
        return (V) null;
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    77
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    78
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    79
    @Override
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    80
    public long getTotalSpace() throws IOException {
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 27565
diff changeset
    81
        throw new UnsupportedOperationException("getTotalSpace");
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    82
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    83
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    84
    @Override
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    85
    public long getUsableSpace() throws IOException {
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 27565
diff changeset
    86
        throw new UnsupportedOperationException("getUsableSpace");
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    87
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    88
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    89
    @Override
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    90
    public long getUnallocatedSpace() throws IOException {
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 27565
diff changeset
    91
        throw new UnsupportedOperationException("getUnallocatedSpace");
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    92
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    93
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    94
    @Override
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    95
    public Object getAttribute(String attribute) throws IOException {
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents: 27565
diff changeset
    96
        throw new UnsupportedOperationException("does not support " + attribute);
9d0388c6b336 8142968: Module System implementation
alanb
parents: 27565
diff changeset
    97
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents: 27565
diff changeset
    98
9d0388c6b336 8142968: Module System implementation
alanb
parents: 27565
diff changeset
    99
    @Override
9d0388c6b336 8142968: Module System implementation
alanb
parents: 27565
diff changeset
   100
    public boolean supportsFileAttributeView(Class<? extends FileAttributeView> type) {
37365
9cc4eb4d7491 8147460: Clean-up jrtfs implementation
sherman
parents: 36511
diff changeset
   101
        return type == BasicFileAttributeView.class ||
9cc4eb4d7491 8147460: Clean-up jrtfs implementation
sherman
parents: 36511
diff changeset
   102
               type == JrtFileAttributeView.class;
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   103
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   104
}