1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package cc
.squirreljme
.jvm
.mle
;
12 import cc
.squirreljme
.jvm
.mle
.brackets
.JarPackageBracket
;
13 import cc
.squirreljme
.jvm
.mle
.exceptions
.MLECallError
;
14 import cc
.squirreljme
.runtime
.cldc
.annotation
.Api
;
15 import cc
.squirreljme
.runtime
.cldc
.annotation
.SquirrelJMEVendorApi
;
16 import java
.io
.InputStream
;
17 import org
.jetbrains
.annotations
.CheckReturnValue
;
18 import org
.jetbrains
.annotations
.Contract
;
19 import org
.jetbrains
.annotations
.NotNull
;
20 import org
.jetbrains
.annotations
.Nullable
;
21 import org
.jetbrains
.annotations
.Range
;
24 * This allows access to the library class path and resources.
28 @SuppressWarnings("UnstableApiUsage")
30 public final class JarPackageShelf
33 * Returns the classpath of the current program.
35 * @return The classpath of the current program.
39 public static native JarPackageBracket
[] classPath();
42 * Checks if the given brackets refer to the same JAR.
44 * @param __a The first JAR.
45 * @param __b The second JAR.
46 * @return If these are equal or not.
47 * @throws MLECallError If either argument is {@code null}.
51 public static native boolean equals(
52 JarPackageBracket __a
, JarPackageBracket __b
)
56 * Returns the libraries which are available to the virtual machine.
58 * @return The libraries that are currently available.
62 public static native JarPackageBracket
[] libraries();
65 * Returns the ID of the specific library.
67 * @param __jar The Jar to get the library ID of.
68 * @return The library ID for the given Jar.
69 * @throws MLECallError If the library is not valid.
73 public static native int libraryId(@NotNull JarPackageBracket __jar
)
77 * Returns the path to the given JAR.
79 * Note that this may or may not be a physical path, it could be a
80 * representation of the JAR file in string form.
82 * @param __jar The JAR to get the path of.
83 * @return The path of the given JAR.
84 * @throws MLECallError If the JAR is not valid.
88 public static native String
libraryPath(@NotNull JarPackageBracket __jar
)
92 * Opens the resource from the input stream.
94 * @param __jar The JAR to open.
95 * @param __rc The resource to load from the given JAR.
96 * @return Input stream to the resource, may be {@code null} if it does
98 * @throws MLECallError If the JAR is not valid or the resource was not
102 @SquirrelJMEVendorApi
104 public static native InputStream
openResource(
105 @NotNull JarPackageBracket __jar
,
106 @NotNull String __rc
)
110 * Returns the prefix code for the class.
112 * @param __jar The Jar to get the prefix code from.
113 * @return The prefix code in the JAR, mapped accordingly to 37 radix,
114 * will return -1 if there is none.
115 * @throws MLECallError If {@code __jar} is null.
118 @SquirrelJMEVendorApi
119 @Range(from
= -1, to
= 1296)
120 public static native int prefixCode(@NotNull JarPackageBracket __jar
)
124 * Reads a section of a JAR representation, note that the format is not
125 * necessarily in the format of a JAR or ZIP file but may exist in SQC
128 * @param __jar The library to read the raw data from.
129 * @param __jarOffset The offset into the raw data.
130 * @param __b The buffer to write into.
131 * @param __o The offset into the buffer.
132 * @param __l The length of the buffer.
133 * @return The number of bytes read from the raw Jar data.
134 * @throws MLECallError On null arguments or if the offset and/or length
135 * exceed the array bounds.
138 @SquirrelJMEVendorApi
140 public static native int rawData(@NotNull JarPackageBracket __jar
,
141 @Range(from
= 0, to
= Integer
.MAX_VALUE
) int __jarOffset
,
143 @Range(from
= 0, to
= Integer
.MAX_VALUE
) int __o
,
144 @Range(from
= 0, to
= Integer
.MAX_VALUE
) int __l
)
148 * Returns the raw size of a given JAR, note that this may not be
149 * the size of a JAR file but a compiled form such a SQC.
151 * @param __jar The JAR to lookup.
152 * @return The raw size of the JAR, this will be a negative value if the
153 * JAR is virtual and its size is not known.
154 * @throws MLECallError If {@code __jar} is null.
157 @SquirrelJMEVendorApi
159 public static native int rawSize(@NotNull JarPackageBracket __jar
)