< prev index next >

src/java.base/share/classes/sun/misc/URLClassPath.java

Print this page

        

@@ -37,10 +37,11 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLConnection;
 import java.net.URLStreamHandler;
 import java.net.URLStreamHandlerFactory;
+import java.nio.ByteBuffer;
 import java.security.AccessControlException;
 import java.security.AccessController;
 import java.security.CodeSigner;
 import java.security.Permission;
 import java.security.PrivilegedExceptionAction;

@@ -797,10 +798,24 @@
                 public String getName() { return name; }
                 public URL getURL() { return url; }
                 public URL getCodeSourceURL() { return csu; }
                 public InputStream getInputStream() throws IOException
                     { return jar.getInputStream(entry); }
+                @Override
+                public ByteBuffer getByteBuffer() throws IOException
+                    { return zipAccess.getByteBuffer(jar, entry); }
+                @Override
+                public byte[] getBytes() throws IOException {
+                    ByteBuffer bb = getByteBuffer();
+                    if (bb.hasArray()) {
+                        return bb.array();
+                    } else {
+                        byte[] bytes = new byte[bb.remaining()];
+                        bb.get(bytes);
+                        return bytes;
+                    }
+                }
                 public int getContentLength()
                     { return (int)entry.getSize(); }
                 public Manifest getManifest() throws IOException
                     { return jar.getManifest(); };
                 public Certificate[] getCertificates()
< prev index next >