├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── j2kt ├── annotations │ └── java │ │ └── com │ │ └── google │ │ └── j2kt │ │ └── annotations │ │ ├── KtNative.java │ │ └── Throws.java ├── blazerc ├── emulation │ ├── README.md │ └── android │ │ ├── README.md │ │ └── java │ │ ├── android │ │ └── util │ │ │ ├── JsonReader.java │ │ │ ├── JsonScope.java │ │ │ ├── JsonToken.java │ │ │ ├── JsonWriter.java │ │ │ └── MalformedJsonException.java │ │ └── com │ │ └── android │ │ └── internal │ │ └── util │ │ └── StringPool.java └── jre │ ├── java │ ├── README.md │ ├── annotations │ │ └── javaemul │ │ │ └── internal │ │ │ └── annotations │ │ │ ├── KtDisabled.java │ │ │ ├── KtIn.java │ │ │ ├── KtName.java │ │ │ ├── KtNative.java │ │ │ ├── KtOut.java │ │ │ └── KtProperty.java │ ├── common │ │ └── javaemul │ │ │ ├── internal │ │ │ └── Exceptions.java │ │ │ └── lang │ │ │ ├── Array.kt │ │ │ ├── Comparator.kt │ │ │ ├── J2ktMonitor.java │ │ │ ├── JavaIterator.kt │ │ │ ├── JavaNumber.kt │ │ │ ├── Object.kt │ │ │ ├── StringBuilder.kt │ │ │ ├── annotations │ │ │ └── WasAutoValue.kt │ │ │ ├── booleanExtensions.kt │ │ │ ├── byteExtensions.kt │ │ │ ├── charExtensions.kt │ │ │ ├── doubleExtensions.kt │ │ │ ├── floatExtensions.kt │ │ │ ├── intExtensions.kt │ │ │ ├── longExtensions.kt │ │ │ ├── shortExtensions.kt │ │ │ └── stringExtensions.kt │ ├── jvm │ │ └── javaemul │ │ │ └── lang │ │ │ ├── J2ktMonitor.kt │ │ │ ├── MutableCollection.kt │ │ │ ├── MutableIterableJvm.kt │ │ │ ├── MutableIteratorJvm.kt │ │ │ ├── MutableListJvm.kt │ │ │ ├── MutableMapJvm.kt │ │ │ ├── MutableSetJvm.kt │ │ │ ├── NativeThrows.kt │ │ │ ├── ThrowableJvm.kt │ │ │ ├── collectionExtensions.kt │ │ │ └── stringJvmExtensions.kt │ └── native │ │ ├── java │ │ ├── io │ │ │ ├── BufferedWriter.java │ │ │ ├── ByteArrayInputStream.java │ │ │ ├── ByteArrayOutputStream.java │ │ │ ├── Closeable.java │ │ │ ├── EOFException.java │ │ │ ├── EOFException.kt │ │ │ ├── File.java │ │ │ ├── File.kt │ │ │ ├── FileInputStream.java │ │ │ ├── FileInputStream.kt │ │ │ ├── FileNotFoundException.java │ │ │ ├── FileNotFoundException.kt │ │ │ ├── FileOutputStream.java │ │ │ ├── FileOutputStream.kt │ │ │ ├── FileWriter.java │ │ │ ├── FilterInputStream.java │ │ │ ├── FilterOutputStream.java │ │ │ ├── Flushable.java │ │ │ ├── IOException.java │ │ │ ├── IOException.kt │ │ │ ├── IOUtils.java │ │ │ ├── InputStream.java │ │ │ ├── InputStreamReader.java │ │ │ ├── OutputStream.java │ │ │ ├── OutputStreamWriter.java │ │ │ ├── PrintStream.java │ │ │ ├── PrintWriter.java │ │ │ ├── Reader.java │ │ │ ├── Serializable.java │ │ │ ├── StringReader.java │ │ │ ├── StringWriter.java │ │ │ ├── UncheckedIOException.java │ │ │ ├── UnsupportedEncodingException.java │ │ │ └── Writer.java │ │ ├── lang │ │ │ ├── Appendable.java │ │ │ ├── ArithmeticException.java │ │ │ ├── ArithmeticException.kt │ │ │ ├── ArrayIndexOutOfBoundsException.java │ │ │ ├── ArrayStoreException.java │ │ │ ├── AssertionError.java │ │ │ ├── AssertionError.kt │ │ │ ├── AutoCloseable.java │ │ │ ├── AutoCloseable.kt │ │ │ ├── Boolean.java │ │ │ ├── Boolean.kt │ │ │ ├── Byte.java │ │ │ ├── Byte.kt │ │ │ ├── CaseMapper.java │ │ │ ├── CharSequence.java │ │ │ ├── Character.java │ │ │ ├── Character.kt │ │ │ ├── Class.java │ │ │ ├── Class.kt │ │ │ ├── ClassCastException.java │ │ │ ├── ClassCastException.kt │ │ │ ├── CloneNotSupportedException.java │ │ │ ├── Cloneable.java │ │ │ ├── Cloneable.kt │ │ │ ├── Comparable.java │ │ │ ├── Deprecated.java │ │ │ ├── Double.java │ │ │ ├── Double.kt │ │ │ ├── Enum.java │ │ │ ├── Enum.kt │ │ │ ├── Error.java │ │ │ ├── Error.kt │ │ │ ├── Exception.java │ │ │ ├── Exception.kt │ │ │ ├── Float.java │ │ │ ├── Float.kt │ │ │ ├── FunctionalInterface.java │ │ │ ├── IllegalArgumentException.java │ │ │ ├── IllegalArgumentException.kt │ │ │ ├── IllegalMonitorStateException.java │ │ │ ├── IllegalStateException.java │ │ │ ├── IllegalStateException.kt │ │ │ ├── IndexOutOfBoundsException.java │ │ │ ├── IndexOutOfBoundsException.kt │ │ │ ├── Integer.java │ │ │ ├── Integer.kt │ │ │ ├── InterruptedException.java │ │ │ ├── Iterable.java │ │ │ ├── Iterable.kt │ │ │ ├── JsException.java │ │ │ ├── Long.java │ │ │ ├── Long.kt │ │ │ ├── MatchException.java │ │ │ ├── Math.java │ │ │ ├── Math.kt │ │ │ ├── NegativeArraySizeException.java │ │ │ ├── NoSuchFieldError.java │ │ │ ├── NullPointerException.java │ │ │ ├── NullPointerException.kt │ │ │ ├── Number.java │ │ │ ├── NumberFormatException.java │ │ │ ├── NumberFormatException.kt │ │ │ ├── Object.java │ │ │ ├── OutOfMemoryError.java │ │ │ ├── OutOfMemoryError.kt │ │ │ ├── Override.java │ │ │ ├── Readable.java │ │ │ ├── Runnable.java │ │ │ ├── RuntimeException.java │ │ │ ├── RuntimeException.kt │ │ │ ├── SafeVarargs.java │ │ │ ├── SecurityException.java │ │ │ ├── Short.java │ │ │ ├── Short.kt │ │ │ ├── StackTraceElement.java │ │ │ ├── StrictMath.java │ │ │ ├── String.java │ │ │ ├── String.kt │ │ │ ├── StringBuffer.java │ │ │ ├── StringBuilder.java │ │ │ ├── StringIndexOutOfBoundsException.java │ │ │ ├── SuppressWarnings.java │ │ │ ├── System.java │ │ │ ├── System.kt │ │ │ ├── Thread.java │ │ │ ├── Thread.kt │ │ │ ├── ThreadLocal.java │ │ │ ├── ThreadLocal.kt │ │ │ ├── Throwable.java │ │ │ ├── Throwable.kt │ │ │ ├── UnsupportedOperationException.java │ │ │ ├── UnsupportedOperationException.kt │ │ │ ├── Void.java │ │ │ ├── annotation │ │ │ │ ├── Annotation.java │ │ │ │ ├── AnnotationFormatError.java │ │ │ │ ├── AnnotationTypeMismatchException.java │ │ │ │ ├── Documented.java │ │ │ │ ├── ElementType.java │ │ │ │ ├── IncompleteAnnotationException.java │ │ │ │ ├── Inherited.java │ │ │ │ ├── Native.java │ │ │ │ ├── Repeatable.java │ │ │ │ ├── Retention.java │ │ │ │ ├── RetentionPolicy.java │ │ │ │ └── Target.java │ │ │ ├── invoke │ │ │ │ ├── CallSite.java │ │ │ │ ├── LambdaMetafactory.java │ │ │ │ ├── MethodHandle.java │ │ │ │ ├── MethodHandles.java │ │ │ │ ├── MethodType.java │ │ │ │ └── SerializedLambda.java │ │ │ ├── ref │ │ │ │ ├── WeakReference.java │ │ │ │ └── WeakReference.kt │ │ │ └── reflect │ │ │ │ ├── Array.java │ │ │ │ └── Type.java │ │ ├── math │ │ │ ├── BigDecimal.java │ │ │ ├── BigInteger.java │ │ │ ├── BitLevel.java │ │ │ ├── Conversion.java │ │ │ ├── Division.java │ │ │ ├── Elementary.java │ │ │ ├── Logical.java │ │ │ ├── MathContext.java │ │ │ ├── Multiplication.java │ │ │ ├── Primality.java │ │ │ └── RoundingMode.java │ │ ├── net │ │ │ ├── CookieHandler.java │ │ │ ├── CookieManager.java │ │ │ ├── CookiePolicy.java │ │ │ ├── CookieStore.java │ │ │ ├── CookieStoreImpl.java │ │ │ ├── HttpCookie.java │ │ │ ├── HttpDate.java │ │ │ ├── HttpDate.kt │ │ │ ├── InetUtil.java │ │ │ ├── InetUtil.kt │ │ │ ├── MalformedURLException.java │ │ │ ├── URI.java │ │ │ ├── URISyntaxException.java │ │ │ ├── URLDecoder.java │ │ │ ├── URLEncoder.java │ │ │ ├── UriCodec.java │ │ │ └── UrlUtils.java │ │ ├── nio │ │ │ ├── BaseByteBuffer.java │ │ │ ├── Buffer.java │ │ │ ├── BufferFactory.java │ │ │ ├── BufferOverflowException.java │ │ │ ├── BufferUnderflowException.java │ │ │ ├── ByteBuffer.java │ │ │ ├── ByteOrder.java │ │ │ ├── CharArrayBuffer.java │ │ │ ├── CharBuffer.java │ │ │ ├── CharSequenceAdapter.java │ │ │ ├── DoubleArrayBuffer.java │ │ │ ├── DoubleBuffer.java │ │ │ ├── FloatArrayBuffer.java │ │ │ ├── FloatBuffer.java │ │ │ ├── HeapByteBuffer.java │ │ │ ├── IntArrayBuffer.java │ │ │ ├── IntBuffer.java │ │ │ ├── InvalidMarkException.java │ │ │ ├── KotlinNativePlatform.java │ │ │ ├── LongArrayBuffer.java │ │ │ ├── LongBuffer.java │ │ │ ├── ReadOnlyBufferException.java │ │ │ ├── ReadOnlyCharArrayBuffer.java │ │ │ ├── ReadOnlyDoubleArrayBuffer.java │ │ │ ├── ReadOnlyFloatArrayBuffer.java │ │ │ ├── ReadOnlyHeapByteBuffer.java │ │ │ ├── ReadOnlyIntArrayBuffer.java │ │ │ ├── ReadOnlyLongArrayBuffer.java │ │ │ ├── ReadOnlyShortArrayBuffer.java │ │ │ ├── ReadWriteCharArrayBuffer.java │ │ │ ├── ReadWriteDoubleArrayBuffer.java │ │ │ ├── ReadWriteFloatArrayBuffer.java │ │ │ ├── ReadWriteHeapByteBuffer.java │ │ │ ├── ReadWriteIntArrayBuffer.java │ │ │ ├── ReadWriteLongArrayBuffer.java │ │ │ ├── ReadWriteShortArrayBuffer.java │ │ │ ├── ShortArrayBuffer.java │ │ │ ├── ShortBuffer.java │ │ │ ├── charset │ │ │ │ ├── CharacterCodingException.java │ │ │ │ ├── Charset.java │ │ │ │ ├── CharsetDecoder.java │ │ │ │ ├── CharsetEncoder.java │ │ │ │ ├── CoderMalfunctionError.java │ │ │ │ ├── CoderResult.java │ │ │ │ ├── CodingErrorAction.java │ │ │ │ ├── IllegalCharsetNameException.java │ │ │ │ ├── MalformedInputException.java │ │ │ │ ├── StandardCharsets.java │ │ │ │ ├── UnmappableCharacterException.java │ │ │ │ └── UnsupportedCharsetException.java │ │ │ └── file │ │ │ │ └── Path.java │ │ ├── security │ │ │ ├── DigestException.java │ │ │ ├── GeneralSecurityException.java │ │ │ ├── InvalidAlgorithmParameterException.java │ │ │ ├── InvalidKeyException.java │ │ │ ├── Key.java │ │ │ ├── KeyException.java │ │ │ ├── MessageDigest.java │ │ │ ├── MessageDigestSpi.java │ │ │ ├── NoSuchAlgorithmException.java │ │ │ ├── NoSuchProviderException.java │ │ │ ├── Provider.java │ │ │ ├── SHA256Digest.java │ │ │ ├── SecureRandom.java │ │ │ ├── SecureRandom.kt │ │ │ └── spec │ │ │ │ ├── AlgorithmParameterSpec.java │ │ │ │ └── KeySpec.java │ │ ├── sql │ │ │ ├── Date.java │ │ │ ├── Time.java │ │ │ └── Timestamp.java │ │ ├── text │ │ │ ├── CollationKey.java │ │ │ ├── Collator.java │ │ │ ├── IOSCollator.java │ │ │ ├── IOSCollator.kt │ │ │ └── ParseException.java │ │ └── util │ │ │ ├── AbstractCollection.java │ │ │ ├── AbstractCollection.kt │ │ │ ├── AbstractList.java │ │ │ ├── AbstractList.kt │ │ │ ├── AbstractMap.java │ │ │ ├── AbstractMapEntry.java │ │ │ ├── AbstractQueue.java │ │ │ ├── AbstractSequentialList.java │ │ │ ├── AbstractSet.java │ │ │ ├── AbstractSet.kt │ │ │ ├── ArrayDeque.java │ │ │ ├── ArrayList.java │ │ │ ├── ArrayList.kt │ │ │ ├── Arrays.java │ │ │ ├── Arrays.kt │ │ │ ├── Base64.java │ │ │ ├── Base64.kt │ │ │ ├── BitSet.java │ │ │ ├── Collection.java │ │ │ ├── Collection.kt │ │ │ ├── Collections.java │ │ │ ├── Comparator.java │ │ │ ├── Comparator.kt │ │ │ ├── Comparators.java │ │ │ ├── ConcurrentModificationException.java │ │ │ ├── ConcurrentModificationException.kt │ │ │ ├── Date.java │ │ │ ├── Date.kt │ │ │ ├── Deque.java │ │ │ ├── DoubleSummaryStatistics.java │ │ │ ├── DuplicateFormatFlagsException.java │ │ │ ├── EmptyStackException.java │ │ │ ├── EnumMap.java │ │ │ ├── EnumSet.java │ │ │ ├── Enumeration.java │ │ │ ├── EventListener.java │ │ │ ├── EventObject.java │ │ │ ├── FormatFlagsConversionMismatchException.java │ │ │ ├── Formattable.java │ │ │ ├── FormattableFlags.java │ │ │ ├── Formatter.java │ │ │ ├── FormatterClosedException.java │ │ │ ├── HashMap.java │ │ │ ├── HashMap.kt │ │ │ ├── HashSet.java │ │ │ ├── IdentityHashMap.java │ │ │ ├── IllegalFormatCodePointException.java │ │ │ ├── IllegalFormatConversionException.java │ │ │ ├── IllegalFormatException.java │ │ │ ├── IllegalFormatFlagsException.java │ │ │ ├── IllegalFormatPrecisionException.java │ │ │ ├── IllegalFormatWidthException.java │ │ │ ├── IntSummaryStatistics.java │ │ │ ├── Iterator.java │ │ │ ├── Iterator.kt │ │ │ ├── LinkedHashMap.java │ │ │ ├── LinkedHashMap.kt │ │ │ ├── LinkedHashSet.java │ │ │ ├── LinkedList.java │ │ │ ├── List.java │ │ │ ├── List.kt │ │ │ ├── ListIterator.java │ │ │ ├── Locale.java │ │ │ ├── Locale.kt │ │ │ ├── LongSummaryStatistics.java │ │ │ ├── Map.java │ │ │ ├── Map.kt │ │ │ ├── MissingFormatArgumentException.java │ │ │ ├── MissingFormatWidthException.java │ │ │ ├── MissingResourceException.java │ │ │ ├── NavigableMap.java │ │ │ ├── NavigableSet.java │ │ │ ├── NoSuchElementException.java │ │ │ ├── NoSuchElementException.kt │ │ │ ├── Objects.java │ │ │ ├── Optional.java │ │ │ ├── OptionalDouble.java │ │ │ ├── OptionalInt.java │ │ │ ├── OptionalLong.java │ │ │ ├── PrimitiveIterator.java │ │ │ ├── PriorityQueue.java │ │ │ ├── Queue.java │ │ │ ├── Random.java │ │ │ ├── RandomAccess.java │ │ │ ├── ReadonlyCollection.java │ │ │ ├── ReadonlyMap.java │ │ │ ├── Set.java │ │ │ ├── Set.kt │ │ │ ├── SortedMap.java │ │ │ ├── SortedSet.java │ │ │ ├── Spliterator.java │ │ │ ├── Spliterators.java │ │ │ ├── Stack.java │ │ │ ├── StringJoiner.java │ │ │ ├── TooManyListenersException.java │ │ │ ├── TreeMap.java │ │ │ ├── TreeSet.java │ │ │ ├── UUID.java │ │ │ ├── UnknownFormatConversionException.java │ │ │ ├── Vector.java │ │ │ ├── concurrent │ │ │ ├── AbstractExecutorService.java │ │ │ ├── BlockingQueue.java │ │ │ ├── Callable.java │ │ │ ├── CancellationException.java │ │ │ ├── CompletionService.java │ │ │ ├── ConcurrentHashMap.java │ │ │ ├── ConcurrentMap.java │ │ │ ├── Delayed.java │ │ │ ├── ExecutionException.java │ │ │ ├── Executor.java │ │ │ ├── ExecutorCompletionService.java │ │ │ ├── ExecutorService.java │ │ │ ├── ExecutorService.kt │ │ │ ├── Executors.java │ │ │ ├── Flow.java │ │ │ ├── Future.java │ │ │ ├── FutureTask.java │ │ │ ├── ImmediateFuture.kt │ │ │ ├── KotlinDelayedFuture.kt │ │ │ ├── KotlinExecutor.java │ │ │ ├── KotlinExecutor.kt │ │ │ ├── KotlinFuture.kt │ │ │ ├── LinkedBlockingQueue.java │ │ │ ├── RejectedExecutionException.java │ │ │ ├── RunnableFuture.java │ │ │ ├── ScheduledExecutorService.java │ │ │ ├── ScheduledFuture.java │ │ │ ├── TimeUnit.java │ │ │ ├── TimeoutException.java │ │ │ ├── atomic │ │ │ │ ├── AtomicBoolean.java │ │ │ │ ├── AtomicBoolean.kt │ │ │ │ ├── AtomicInteger.java │ │ │ │ ├── AtomicInteger.kt │ │ │ │ ├── AtomicIntegerArray.java │ │ │ │ ├── AtomicIntegerArray.kt │ │ │ │ ├── AtomicLong.java │ │ │ │ ├── AtomicLong.kt │ │ │ │ ├── AtomicLongArray.java │ │ │ │ ├── AtomicLongArray.kt │ │ │ │ ├── AtomicReference.java │ │ │ │ ├── AtomicReference.kt │ │ │ │ ├── AtomicReferenceArray.java │ │ │ │ └── AtomicReferenceArray.kt │ │ │ └── locks │ │ │ │ ├── Lock.java │ │ │ │ ├── ReentrantLock.java │ │ │ │ └── ReentrantLock.kt │ │ │ ├── function │ │ │ ├── BiConsumer.java │ │ │ ├── BiFunction.java │ │ │ ├── BiPredicate.java │ │ │ ├── BinaryOperator.java │ │ │ ├── BooleanSupplier.java │ │ │ ├── Consumer.java │ │ │ ├── DoubleBinaryOperator.java │ │ │ ├── DoubleConsumer.java │ │ │ ├── DoubleFunction.java │ │ │ ├── DoublePredicate.java │ │ │ ├── DoubleSupplier.java │ │ │ ├── DoubleToIntFunction.java │ │ │ ├── DoubleToLongFunction.java │ │ │ ├── DoubleUnaryOperator.java │ │ │ ├── Function.java │ │ │ ├── IntBinaryOperator.java │ │ │ ├── IntConsumer.java │ │ │ ├── IntFunction.java │ │ │ ├── IntPredicate.java │ │ │ ├── IntSupplier.java │ │ │ ├── IntToDoubleFunction.java │ │ │ ├── IntToLongFunction.java │ │ │ ├── IntUnaryOperator.java │ │ │ ├── LongBinaryOperator.java │ │ │ ├── LongConsumer.java │ │ │ ├── LongFunction.java │ │ │ ├── LongPredicate.java │ │ │ ├── LongSupplier.java │ │ │ ├── LongToDoubleFunction.java │ │ │ ├── LongToIntFunction.java │ │ │ ├── LongUnaryOperator.java │ │ │ ├── ObjDoubleConsumer.java │ │ │ ├── ObjIntConsumer.java │ │ │ ├── ObjLongConsumer.java │ │ │ ├── Predicate.java │ │ │ ├── Supplier.java │ │ │ ├── ToDoubleBiFunction.java │ │ │ ├── ToDoubleFunction.java │ │ │ ├── ToIntBiFunction.java │ │ │ ├── ToIntFunction.java │ │ │ ├── ToLongBiFunction.java │ │ │ ├── ToLongFunction.java │ │ │ └── UnaryOperator.java │ │ │ ├── logging │ │ │ ├── Formatter.java │ │ │ ├── Handler.java │ │ │ ├── Level.java │ │ │ ├── LogManager.java │ │ │ ├── LogRecord.java │ │ │ ├── Logger.java │ │ │ ├── SimpleConsoleLogHandler.java │ │ │ └── SimpleFormatter.java │ │ │ ├── regex │ │ │ ├── Matcher.java │ │ │ ├── Matcher.kt │ │ │ ├── Pattern.java │ │ │ ├── Pattern.kt │ │ │ └── PatternSyntaxException.java │ │ │ ├── stream │ │ │ ├── BaseStream.java │ │ │ ├── Collector.java │ │ │ ├── CollectorImpl.java │ │ │ ├── Collectors.java │ │ │ ├── DoubleStream.java │ │ │ ├── DoubleStreamImpl.java │ │ │ ├── IntStream.java │ │ │ ├── IntStreamImpl.java │ │ │ ├── LongStream.java │ │ │ ├── LongStreamImpl.java │ │ │ ├── Stream.java │ │ │ ├── StreamImpl.java │ │ │ ├── StreamSupport.java │ │ │ └── TerminatableStream.java │ │ │ └── zip │ │ │ ├── Adler32.java │ │ │ ├── Adler32.kt │ │ │ ├── CRC32.java │ │ │ ├── CRC32.kt │ │ │ ├── Checksum.java │ │ │ ├── DataFormatException.java │ │ │ ├── Deflater.java │ │ │ ├── DeflaterImpl.java │ │ │ ├── DeflaterImpl.kt │ │ │ ├── DeflaterOutputStream.java │ │ │ ├── GZIPOutputStream.java │ │ │ ├── Inflater.java │ │ │ ├── InflaterImpl.java │ │ │ ├── InflaterImpl.kt │ │ │ ├── InflaterOutputStream.java │ │ │ ├── NativeZipStream.java │ │ │ ├── NativeZipStream.kt │ │ │ └── ZipException.java │ │ ├── javaemul │ │ ├── internal │ │ │ ├── ArrayHelper.java │ │ │ ├── CollectionHelper.java │ │ │ ├── ConsoleLogger.java │ │ │ ├── DebugDefine.java │ │ │ ├── DebugDefine.kt │ │ │ ├── EmulatedCharset.java │ │ │ ├── InternalPreconditions.java │ │ │ ├── KtNativeUtils.java │ │ │ ├── NumberDecoder.kt │ │ │ └── debug_define.h │ │ └── lang │ │ │ ├── CauseHolder.kt │ │ │ ├── InitCauseCapable.kt │ │ │ ├── J2ktMonitor.kt │ │ │ ├── MutableCollectionJvm.kt │ │ │ ├── MutableIterableJvm.kt │ │ │ ├── MutableIteratorJvm.kt │ │ │ ├── MutableListJvm.kt │ │ │ ├── MutableMapJvm.kt │ │ │ ├── MutableSetJvm.kt │ │ │ ├── NativeThrows.kt │ │ │ ├── ThrowableJvm.kt │ │ │ ├── collectionExtensions.kt │ │ │ ├── iterableExtensions.kt │ │ │ ├── iteratorExtensions.kt │ │ │ ├── listExtensions.kt │ │ │ ├── mapExtensions.kt │ │ │ ├── stringNativeExtensions.kt │ │ │ └── throwableExtensions.kt │ │ ├── javax │ │ ├── annotation │ │ │ └── processing │ │ │ │ └── Generated.java │ │ └── crypto │ │ │ ├── Mac.java │ │ │ ├── Mac.kt │ │ │ ├── SecretKey.java │ │ │ ├── ShortBufferException.java │ │ │ └── spec │ │ │ └── SecretKeySpec.java │ │ ├── kotlin │ │ ├── Cloneable.kt │ │ ├── Synchronized.kt │ │ └── jvm │ │ │ ├── Class.kt │ │ │ └── Throws.kt │ │ └── module-info.java │ └── javatests │ ├── interop │ ├── ImpliedPropertyNameTest.kt │ ├── JavaGetters.java │ ├── README.md │ └── collections │ │ ├── J2KtCollections.java │ │ └── J2KtCollectionsInteropTest.kt │ └── smoke │ ├── ArraysTest.java │ ├── AtomicTest.java │ ├── BitSetTest.java │ ├── CharacterTest.java │ ├── ClassTest.java │ ├── CollatorTest.java │ ├── CollectionsTest.java │ ├── ConcurrentTest.java │ ├── DateTest.java │ ├── DeflaterTest.java │ ├── ErasureTest.java │ ├── FormatterTest.java │ ├── HttpCookieTest.java │ ├── ImmediateFutureTest.kt │ ├── InflaterTest.java │ ├── IoTest.java │ ├── KotlinDelayedFutureTest.kt │ ├── KotlinExecutorTest.kt │ ├── LocaleTest.java │ ├── LoggingTest.java │ ├── MathTest.java │ ├── OldAndroidChecksumTest.java │ ├── OldAndroidURITest.java │ ├── OldURITest.java │ ├── PrimitivesTest.java │ ├── RandomTest.java │ ├── ReflectArrayTest.java │ ├── RegexTest.java │ ├── SecurityTest.java │ ├── StringTest.java │ ├── SystemTest.java │ ├── TestHarness.java │ ├── ThreadTest.java │ ├── ThrowableTest.java │ ├── URITest.java │ ├── UUIDTest.java │ ├── UrlEncodingTest.java │ └── package-info.java └── kmpbench ├── README.md ├── com └── google │ └── apps │ └── xplat │ └── kmpbench │ ├── app │ ├── ios │ │ ├── BenchmarkTest.swift │ │ ├── ContentView.swift │ │ ├── IosBenchmarkManager.kt │ │ ├── KmpBenchApp.swift │ │ ├── PerfgateLogger.h │ │ ├── PerfgateLogger.m │ │ └── info.plist │ └── jvm │ │ └── JvmBenchmarkRunner.kt │ ├── combination │ ├── BenchmarkManager.kt │ └── CombinedBenchmark.kt │ └── perfgate │ └── ConfigGenerator.java ├── gencode_snapshot ├── README.md └── octane │ ├── NavierStokesBenchmark.kt │ ├── RayTraceBenchmark.kt │ ├── RichardsBenchmark.kt │ ├── navierstokes │ ├── Field.kt │ ├── FluidField.kt │ └── NavierStokes.kt │ ├── raytrace │ ├── Background.kt │ ├── BaseMaterial.kt │ ├── Camera.kt │ ├── Chessboard.kt │ ├── Color.kt │ ├── Engine.kt │ ├── IntersectionInfo.kt │ ├── Light.kt │ ├── MaterialSolid.kt │ ├── Plane.kt │ ├── Ray.kt │ ├── RayTrace.kt │ ├── Scene.kt │ ├── Shape.kt │ ├── Sphere.kt │ └── Vector.kt │ └── richards │ ├── DeviceTask.kt │ ├── HandlerTask.kt │ ├── IdleTask.kt │ ├── Packet.kt │ ├── Richards.kt │ ├── Scheduler.kt │ ├── Task.kt │ ├── TaskControlBlock.kt │ └── WorkerTask.kt ├── java ├── com │ └── google │ │ └── j2cl │ │ ├── benchmarking │ │ └── framework │ │ │ ├── AbstractBenchmark.java │ │ │ ├── BenchmarkExecutor.java │ │ │ ├── BenchmarkResult.java │ │ │ ├── Clock.java │ │ │ ├── CollectionUtilizer.java │ │ │ └── Platform.java │ │ └── benchmarks │ │ ├── AllBenchmarks.java │ │ ├── octane │ │ ├── Box2dBenchmark.java │ │ ├── DeltaBlueBenchmark.java │ │ ├── NavierStokesBenchmark.java │ │ ├── RayTraceBenchmark.java │ │ ├── RichardsBenchmark.java │ │ ├── deltablue │ │ │ ├── BinaryConstraint.java │ │ │ ├── Constraint.java │ │ │ ├── DeltaBlue.java │ │ │ ├── Direction.java │ │ │ ├── EditConstraint.java │ │ │ ├── EqualityConstraint.java │ │ │ ├── Plan.java │ │ │ ├── Planner.java │ │ │ ├── ScaleConstraint.java │ │ │ ├── StayConstraint.java │ │ │ ├── Strength.java │ │ │ ├── UnaryConstraint.java │ │ │ └── Variable.java │ │ ├── navierstokes │ │ │ ├── Field.java │ │ │ ├── FluidField.java │ │ │ └── NavierStokes.java │ │ ├── raytrace │ │ │ ├── Background.java │ │ │ ├── BaseMaterial.java │ │ │ ├── Camera.java │ │ │ ├── Chessboard.java │ │ │ ├── Color.java │ │ │ ├── Engine.java │ │ │ ├── IntersectionInfo.java │ │ │ ├── Light.java │ │ │ ├── MaterialSolid.java │ │ │ ├── Plane.java │ │ │ ├── Ray.java │ │ │ ├── RayTrace.java │ │ │ ├── Scene.java │ │ │ ├── Shape.java │ │ │ ├── Sphere.java │ │ │ └── Vector.java │ │ └── richards │ │ │ ├── DeviceTask.java │ │ │ ├── HandlerTask.java │ │ │ ├── IdleTask.java │ │ │ ├── Packet.java │ │ │ ├── Richards.java │ │ │ ├── Scheduler.java │ │ │ ├── Task.java │ │ │ ├── TaskControlBlock.java │ │ │ └── WorkerTask.java │ │ └── simple │ │ └── Fibonacci.java └── jarjar-rules.txt ├── kotlin └── com │ └── google │ └── j2cl │ ├── benchmarking │ └── framework │ │ ├── AbstractBenchmark.kt │ │ ├── BenchmarkExecutor.kt │ │ ├── BenchmarkResult.kt │ │ ├── CollectionUtilizer.kt │ │ └── Platform.kt │ └── benchmarks │ ├── AllBenchmarks.kt │ └── simple │ └── Fibonacci.kt └── update_gencode_snapshot.sh /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to Contribute 2 | 3 | We'd love to accept your patches and contributions to this project. There are 4 | just a few small guidelines you need to follow. 5 | 6 | ## Contributor License Agreement 7 | 8 | Contributions to this project must be accompanied by a Contributor License 9 | Agreement (CLA). You (or your employer) retain the copyright to your 10 | contribution; this simply gives us permission to use and redistribute your 11 | contributions as part of the project. Head over to 12 | to see your current agreements on file or 13 | to sign a new one. 14 | 15 | You generally only need to submit a CLA once, so if you've already submitted one 16 | (even if it was for a different project), you probably don't need to do it 17 | again. 18 | 19 | ## Code Reviews 20 | 21 | All submissions, including submissions by project members, require review. We 22 | use GitHub pull requests for this purpose. Consult 23 | [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more 24 | information on using pull requests. 25 | 26 | ## Community Guidelines 27 | 28 | This project follows 29 | [Google's Open Source Community Guidelines](https://opensource.google/conduct/). -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Xplat+ Open Source Code 2 | 3 | Note: This is not an officially supported Google product 4 | 5 | Packages: 6 | 7 | - j2kt/jre: Java Runtime Environment emulation code for migrating from Java to 8 | Kotlin Native 9 | - kmpbench: Benchmarks comparing transpiled Java and Kotlin performance 10 | -------------------------------------------------------------------------------- /j2kt/blazerc: -------------------------------------------------------------------------------- 1 | import %workspace%/third_party/java/j2cl/blazerc 2 | 3 | build --strategy=J2kt=dynamic 4 | build --strategy=J2ktStrip=dynamic 5 | # J2KT is in the critical path for a single target, so minimize worker count. 6 | build --worker_max_instances=J2kt=1 7 | build --worker_max_instances=J2ktStrip=1 -------------------------------------------------------------------------------- /j2kt/emulation/README.md: -------------------------------------------------------------------------------- 1 | Potentially temporary subsets of required libraries that don't (fully) compile 2 | with J2kt at this point, typically due to use of reflection. -------------------------------------------------------------------------------- /j2kt/emulation/android/README.md: -------------------------------------------------------------------------------- 1 | Copied from: 2 | https://android.googlesource.com/platform/libcore/+/refs/heads/marshmallow-mr3-release/luni/src/main/ 3 | 4 | May include slight adjustments and "g4 fix" formatting. -------------------------------------------------------------------------------- /j2kt/emulation/android/java/android/util/MalformedJsonException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package android.util; 18 | 19 | import java.io.IOException; 20 | 21 | /** 22 | * Thrown when a reader encounters malformed JSON. Some syntax errors can be ignored by calling 23 | * {@link JsonReader#setLenient(boolean)}. 24 | */ 25 | public final class MalformedJsonException extends IOException { 26 | private static final long serialVersionUID = 1L; 27 | 28 | public MalformedJsonException(String message) { 29 | super(message); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /j2kt/jre/java/annotations/javaemul/internal/annotations/KtDisabled.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.internal.annotations; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Disables the method in Kotlin by generating empty body for void methods, or returning default 26 | * value for non-void methods. 27 | */ 28 | @Retention(RetentionPolicy.RUNTIME) 29 | @Target(ElementType.METHOD) 30 | @Documented 31 | public @interface KtDisabled {} 32 | -------------------------------------------------------------------------------- /j2kt/jre/java/annotations/javaemul/internal/annotations/KtProperty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.internal.annotations; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** Maps a Java field or getter method to a Kotlin property. May be combined with {@code KtName}. */ 25 | @Retention(RetentionPolicy.RUNTIME) 26 | @Target(ElementType.METHOD) 27 | @Documented 28 | public @interface KtProperty {} 29 | -------------------------------------------------------------------------------- /j2kt/jre/java/common/javaemul/lang/J2ktMonitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.lang; 17 | 18 | import javaemul.internal.annotations.KtNative; 19 | import org.jspecify.annotations.NullMarked; 20 | 21 | /** 22 | * A monitor for synchronized blocks. Maps to a regular class for JVM and an actual native monitor 23 | * implementation for native. 24 | */ 25 | @KtNative 26 | @NullMarked 27 | public class J2ktMonitor {} 28 | -------------------------------------------------------------------------------- /j2kt/jre/java/common/javaemul/lang/JavaIterator.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.lang 17 | 18 | interface JavaIterator : MutableIteratorJvm { 19 | override fun remove() { 20 | throw UnsupportedOperationException() 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /j2kt/jre/java/common/javaemul/lang/JavaNumber.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.lang 17 | 18 | /** Bridge class for java.lang.Number. */ 19 | abstract class JavaNumber : kotlin.Number() { 20 | override fun toByte() = toInt().toByte() 21 | 22 | override fun toShort() = toInt().toShort() 23 | 24 | override fun toChar() = toInt().toChar() 25 | } 26 | -------------------------------------------------------------------------------- /j2kt/jre/java/common/javaemul/lang/Object.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.lang 17 | 18 | import java.lang.Class 19 | import kotlin.jvm.javaObjectType 20 | 21 | fun T.getClass(): Class = this::class.javaObjectType as Class 22 | -------------------------------------------------------------------------------- /j2kt/jre/java/common/javaemul/lang/annotations/WasAutoValue.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.lang.annotations 17 | 18 | /** Denotes that an {@code @AutoValue} annotation originally existed on this type. */ 19 | @Retention(AnnotationRetention.RUNTIME) 20 | @Target(AnnotationTarget.CLASS) 21 | annotation class WasAutoValue { 22 | /** Denotes that an {@code @AutoValue.Builder} annotation originally existed on this type. */ 23 | @Retention(AnnotationRetention.RUNTIME) 24 | @Target(AnnotationTarget.CLASS) 25 | annotation class Builder {} 26 | } 27 | -------------------------------------------------------------------------------- /j2kt/jre/java/common/javaemul/lang/booleanExtensions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.lang 17 | 18 | import java.lang.Boolean as JavaBoolean 19 | 20 | /** 21 | * Pseudo-constructor for emulated java.lang.Boolean. 22 | * 23 | * See regular JRE API documentation for other methods in this file. 24 | */ 25 | operator fun Boolean.Companion.invoke(b: Boolean): Boolean = 26 | // In Kotlin JVM, java.lang.Boolean(b) is not assignable to kotlin.Boolean without the extra cast. 27 | JavaBoolean(b) as Boolean 28 | 29 | operator fun Boolean.Companion.invoke(s: String?): Boolean = JavaBoolean(s) as Boolean 30 | 31 | fun Boolean.booleanValue(): Boolean = this 32 | -------------------------------------------------------------------------------- /j2kt/jre/java/common/javaemul/lang/charExtensions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.lang 17 | 18 | import java.lang.Character as JavaCharacter 19 | 20 | /** 21 | * Pseudo-constructor for emulated java.lang.Character. 22 | * 23 | * See regular JRE API documentation for other methods in this file. 24 | */ 25 | operator fun Char.Companion.invoke(c: Char): Char = JavaCharacter(c) as Char 26 | 27 | fun Char.shr(pos: Int): Int = toInt().shr(pos) 28 | 29 | fun Char.ushr(pos: Int): Int = toInt().ushr(pos) 30 | 31 | operator fun Char.unaryMinus(): Int = toInt().unaryMinus() 32 | -------------------------------------------------------------------------------- /j2kt/jre/java/common/javaemul/lang/doubleExtensions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.lang 17 | 18 | import java.lang.Double as JavaDouble 19 | 20 | /** 21 | * Pseudo-constructor for emulated java.lang.Double. 22 | * 23 | * See regular JRE API documentation for other methods in this file. 24 | */ 25 | operator fun Double.Companion.invoke(d: Double): Double = JavaDouble(d) as Double 26 | 27 | operator fun Double.Companion.invoke(s: String): Double = JavaDouble(s) as Double 28 | 29 | inline fun Double.toInt_toByte() = toInt().toByte() 30 | 31 | inline fun Double.toInt_toShort() = toInt().toShort() 32 | -------------------------------------------------------------------------------- /j2kt/jre/java/common/javaemul/lang/floatExtensions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.lang 17 | 18 | import java.lang.Float as JavaFloat 19 | 20 | /** 21 | * Pseudo-constructor for emulated java.lang.Float. 22 | * 23 | * See regular JRE API documentation for other methods in this file. 24 | */ 25 | operator fun Float.Companion.invoke(f: Float): Float = JavaFloat(f) as Float 26 | 27 | operator fun Float.Companion.invoke(s: String): Float = JavaFloat(s) as Float 28 | 29 | inline fun Float.toInt_toByte() = toInt().toByte() 30 | 31 | inline fun Float.toInt_toShort() = toInt().toShort() 32 | -------------------------------------------------------------------------------- /j2kt/jre/java/common/javaemul/lang/intExtensions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.lang 17 | 18 | import java.lang.Integer as JavaInteger 19 | 20 | /** 21 | * Pseudo-constructor for emulated java.lang.Integer. 22 | * 23 | * See regular JRE API documentation for other methods in this file. 24 | */ 25 | operator fun Int.Companion.invoke(i: Int): Int = JavaInteger(i) as Int 26 | 27 | operator fun Int.Companion.invoke(s: String): Int = JavaInteger(s) as Int 28 | -------------------------------------------------------------------------------- /j2kt/jre/java/common/javaemul/lang/longExtensions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.lang 17 | 18 | import java.lang.Long as JavaLong 19 | 20 | /** 21 | * Pseudo-constructor for emulated java.lang.Long. 22 | * 23 | * See regular JRE API documentation for other methods in this file. 24 | */ 25 | operator fun Long.Companion.invoke(l: Long): Long = JavaLong(l) as Long 26 | 27 | operator fun Long.Companion.invoke(s: String): Long = JavaLong(s) as Long 28 | -------------------------------------------------------------------------------- /j2kt/jre/java/jvm/javaemul/lang/J2ktMonitor.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | *a 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.lang 17 | 18 | typealias J2ktMonitor = Any 19 | -------------------------------------------------------------------------------- /j2kt/jre/java/jvm/javaemul/lang/MutableCollection.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.lang 17 | 18 | /** A KMP subtype of MutableCollection with all the additional methods of JVM's MutableCollection */ 19 | typealias MutableCollectionJvm = MutableCollection 20 | -------------------------------------------------------------------------------- /j2kt/jre/java/jvm/javaemul/lang/MutableIterableJvm.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.lang 17 | 18 | /** A KMP subtype of MutableIterable with all the additional methods of JVM's MutableIterable */ 19 | typealias MutableIterableJvm = MutableIterable 20 | 21 | // Make it possible to instantiate with a lambda, like a fun interface. 22 | inline fun MutableIterableJvm( 23 | crossinline iteratorFn: () -> MutableIterator 24 | ): MutableIterableJvm = 25 | object : MutableIterableJvm { 26 | override fun iterator(): MutableIterator = iteratorFn() 27 | } 28 | -------------------------------------------------------------------------------- /j2kt/jre/java/jvm/javaemul/lang/MutableIteratorJvm.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.lang 17 | 18 | /** A KMP subtype of MutableIterator with all the additional methods of JVM's MutableIterator */ 19 | typealias MutableIteratorJvm = MutableIterator 20 | -------------------------------------------------------------------------------- /j2kt/jre/java/jvm/javaemul/lang/MutableListJvm.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.lang 17 | 18 | /** A KMP subtype of MutableList with all the additional methods of JVM's MutableList */ 19 | typealias MutableListJvm = MutableList 20 | -------------------------------------------------------------------------------- /j2kt/jre/java/jvm/javaemul/lang/MutableMapJvm.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.lang 17 | 18 | /** A KMP subtype of MutableMap with all the additional methods of JVM's MutableMap */ 19 | typealias MutableMapJvm = MutableMap 20 | -------------------------------------------------------------------------------- /j2kt/jre/java/jvm/javaemul/lang/MutableSetJvm.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.lang 17 | 18 | /** A KMP subtype of MutableSet with all the additional methods of JVM's MutableSet */ 19 | typealias MutableSetJvm = MutableSet 20 | -------------------------------------------------------------------------------- /j2kt/jre/java/jvm/javaemul/lang/NativeThrows.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | @file:OptIn(ExperimentalMultiplatform::class) 17 | 18 | package javaemul.lang 19 | 20 | import kotlin.reflect.KClass 21 | 22 | /** An annotation which maps to [kotlin.Throws] on Kotlin Native. */ 23 | @Target( 24 | AnnotationTarget.FUNCTION, 25 | AnnotationTarget.PROPERTY_GETTER, 26 | AnnotationTarget.PROPERTY_SETTER, 27 | AnnotationTarget.CONSTRUCTOR 28 | ) 29 | @Retention(AnnotationRetention.SOURCE) 30 | @OptionalExpectation 31 | expect annotation class NativeThrows(vararg val exceptionClasses: KClass) 32 | -------------------------------------------------------------------------------- /j2kt/jre/java/jvm/javaemul/lang/ThrowableJvm.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package javaemul.lang 18 | 19 | /** KMP version of throwable with the additional methods of Throwable from Kotlin/JVM */ 20 | typealias ThrowableJvm = kotlin.Throwable 21 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/io/EOFException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.io; 17 | 18 | import static javaemul.internal.KtNativeUtils.ktNative; 19 | 20 | import javaemul.internal.annotations.KtNative; 21 | import org.jspecify.annotations.NullMarked; 22 | import org.jspecify.annotations.Nullable; 23 | 24 | @NullMarked 25 | @KtNative 26 | public class EOFException extends IOException { 27 | 28 | public EOFException(@Nullable String message) { 29 | ktNative(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/io/EOFException.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package java.io 17 | 18 | import kotlinx.io.EOFException as KotlinXEOFException 19 | 20 | // Note: We use an alias here so that transpiled code does not need to import 21 | // the kotlinx class directly, which would require a direct build dependency. 22 | typealias EOFException = KotlinXEOFException 23 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/io/FileNotFoundException.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package java.io 17 | 18 | import kotlinx.io.files.FileNotFoundException as KotlinXFileNotFoundException 19 | 20 | // Note: We use an alias here so that transpiled code does not need to import 21 | // the kotlinx class directly, which would require a direct build dependency. 22 | typealias FileNotFoundException = KotlinXFileNotFoundException 23 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/io/IOException.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package java.io 17 | 18 | import kotlinx.io.IOException as KotlinXIOException 19 | 20 | // Note: We use an alias here so that transpiled code does not need to import 21 | // the kotlinx class directly, which would require a direct build dependency. 22 | typealias IOException = KotlinXIOException 23 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/io/Serializable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.io; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** Provided for interoperability. The Java serialization protocol is explicitly not supported. */ 21 | @NullMarked 22 | public interface Serializable {} 23 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/io/UnsupportedEncodingException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.io; 17 | 18 | /** 19 | * A character encoding is not supported - [Sun's 21 | * docs]. 22 | */ 23 | public class UnsupportedEncodingException extends IOException { 24 | 25 | public UnsupportedEncodingException() {} 26 | 27 | public UnsupportedEncodingException(String msg) { 28 | super(msg); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/ArithmeticException.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package java.lang 17 | 18 | import javaemul.lang.CauseHolder 19 | import javaemul.lang.InitCauseCapable 20 | 21 | open class ArithmeticException(message: kotlin.String? = null) : 22 | kotlin.ArithmeticException(message), InitCauseCapable { 23 | override val causeHolder = CauseHolder() 24 | override val cause 25 | get() = causeHolder.cause 26 | } 27 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/ArrayStoreException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.lang; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | import org.jspecify.annotations.Nullable; 20 | 21 | /** 22 | * See the 23 | * official Java API doc for details. 24 | */ 25 | @NullMarked 26 | public class ArrayStoreException extends RuntimeException { 27 | 28 | public ArrayStoreException() { 29 | } 30 | 31 | public ArrayStoreException(@Nullable String message) { 32 | super(message); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/AutoCloseable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.lang; 17 | 18 | import javaemul.internal.annotations.KtNative; 19 | import org.jspecify.annotations.NullMarked; 20 | 21 | /** 22 | * See the official 23 | * Java API doc for details. 24 | */ 25 | @NullMarked 26 | // TODO(b/272238387): Map to kotlin.AutoCloseable when that's available in Kotlin JVM and J2cl 27 | @KtNative 28 | public interface AutoCloseable { 29 | 30 | /** 31 | * Closes this resource. 32 | */ 33 | void close() throws Exception; 34 | } 35 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/AutoCloseable.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.lang 17 | 18 | // TODO(b/272238387): Remove typealios once kotlin.AutoCloseable is available in Kotlin JVM and J2cl 19 | typealias AutoCloseable = kotlin.AutoCloseable 20 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/CaseMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.lang; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** Performs case operations. Abstracted so can be platform specific. */ 21 | @NullMarked 22 | final class CaseMapper { 23 | 24 | public static char charToLowerCase(char c) { 25 | return String.valueOf(c).toLowerCase().charAt(0); 26 | } 27 | 28 | public static char charToUpperCase(char c) { 29 | return String.valueOf(c).toUpperCase().charAt(0); 30 | } 31 | 32 | private CaseMapper() {} 33 | } 34 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/ClassCastException.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package java.lang 17 | 18 | import javaemul.lang.CauseHolder 19 | import javaemul.lang.InitCauseCapable 20 | 21 | open class ClassCastException(message: kotlin.String? = null) : 22 | kotlin.ClassCastException(message), InitCauseCapable { 23 | override val causeHolder = CauseHolder() 24 | override val cause 25 | get() = causeHolder.cause 26 | } 27 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/CloneNotSupportedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.lang; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | import org.jspecify.annotations.Nullable; 20 | 21 | /** 22 | * See 23 | * the official Java API doc for details. 24 | */ 25 | @NullMarked 26 | public class CloneNotSupportedException extends Exception { 27 | 28 | public CloneNotSupportedException() { 29 | } 30 | 31 | public CloneNotSupportedException(@Nullable String msg) { 32 | super(msg); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/Cloneable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package java.lang; 19 | 20 | import javaemul.internal.annotations.KtNative; 21 | import org.jspecify.annotations.NullMarked; 22 | 23 | @KtNative(name = "kotlin.Cloneable") 24 | @NullMarked 25 | public interface Cloneable {} 26 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/Cloneable.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.lang 17 | 18 | /** Indicates that a class implements clone(). */ 19 | interface Cloneable { 20 | fun clone(): Any 21 | } 22 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/Deprecated.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.lang; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | 22 | /** 23 | * A program element annotated @Deprecated is one that programmers are 24 | * discouraged from using, typically because it is dangerous, or because a 25 | * better alternative exists. [Sun 27 | * docs] 28 | */ 29 | @Documented 30 | @Retention(RetentionPolicy.RUNTIME) 31 | public @interface Deprecated { 32 | } 33 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/Enum.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.lang 17 | 18 | object Enum { 19 | // Not supported in J2KT Native 20 | fun > valueOf(enumType: Class, name: kotlin.String): T { 21 | throw UnsupportedOperationException() 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/Error.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package java.lang 17 | 18 | import javaemul.lang.CauseHolder 19 | import javaemul.lang.InitCauseCapable 20 | 21 | open class Error(message: kotlin.String? = null) : kotlin.Error(message), InitCauseCapable { 22 | override val causeHolder = CauseHolder() 23 | override val cause 24 | get() = causeHolder.cause 25 | 26 | constructor(message: kotlin.String?, cause: kotlin.Throwable?) : this(message) { 27 | initCause(cause) 28 | } 29 | 30 | constructor(cause: kotlin.Throwable?) : this(cause?.toString(), cause) 31 | } 32 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/FunctionalInterface.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.lang; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Used to declare interfaces which must have a single abstract method. 26 | */ 27 | @Documented 28 | @Retention(value = RetentionPolicy.RUNTIME) 29 | @Target(value = ElementType.TYPE) 30 | public @interface FunctionalInterface { 31 | } -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/IllegalStateException.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package java.lang 17 | 18 | import javaemul.lang.CauseHolder 19 | import javaemul.lang.InitCauseCapable 20 | 21 | open class IllegalStateException(message: kotlin.String? = null) : 22 | kotlin.IllegalStateException(message), InitCauseCapable { 23 | override val causeHolder = CauseHolder() 24 | override val cause 25 | get() = causeHolder.cause 26 | 27 | constructor(message: kotlin.String?, cause: kotlin.Throwable?) : this(message) { 28 | initCause(cause) 29 | } 30 | 31 | constructor(cause: kotlin.Throwable?) : this(cause?.toString(), cause) 32 | } 33 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/IndexOutOfBoundsException.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package java.lang 17 | 18 | import javaemul.lang.CauseHolder 19 | import javaemul.lang.InitCauseCapable 20 | 21 | open class IndexOutOfBoundsException(message: kotlin.String? = null) : 22 | kotlin.IndexOutOfBoundsException(message), InitCauseCapable { 23 | override val causeHolder = CauseHolder() 24 | override val cause 25 | get() = causeHolder.cause 26 | } 27 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/InterruptedException.java: -------------------------------------------------------------------------------- 1 | // CHECKSTYLE_OFF: Copyrighted to Guava Authors. 2 | /* 3 | * Copyright (C) 2012 The Guava Authors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | // CHECKSTYLE_ON 18 | 19 | package java.lang; 20 | 21 | import org.jspecify.annotations.NullMarked; 22 | import org.jspecify.annotations.Nullable; 23 | 24 | /** 25 | * Minimal emulation of {@link java.lang.InterruptedException}, that should only be used in method 26 | * signatures. 27 | */ 28 | @NullMarked 29 | public class InterruptedException extends Exception { 30 | public InterruptedException() { } 31 | 32 | public InterruptedException(@Nullable String message) { 33 | super(message); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/Iterable.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.lang 17 | 18 | import java.util.Spliterator 19 | import java.util.Spliterators 20 | import java.util.function.Consumer 21 | 22 | fun interface Iterable : MutableIterable { 23 | fun forEach(consumer: Consumer) { 24 | forEach(consumer::accept) 25 | } 26 | 27 | fun spliterator(): Spliterator = Spliterators.spliteratorUnknownSize(iterator(), 0) 28 | } 29 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/JsException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package java.lang; 17 | 18 | import javaemul.internal.annotations.KtNative; 19 | 20 | /** Emulation of JsException class defined in the J2CL JRE. */ 21 | @KtNative // Can only be used in J2CL. 22 | public class JsException extends RuntimeException {} 23 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/MatchException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.lang; 17 | 18 | /** 19 | * See the 21 | * official Java API doc for details. 22 | */ 23 | public class MatchException extends RuntimeException { 24 | 25 | public MatchException() {} 26 | 27 | public MatchException(String message, Throwable cause) { 28 | super(message, cause); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/NegativeArraySizeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.lang; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | import org.jspecify.annotations.Nullable; 20 | 21 | /** 22 | * See the 24 | * official Java API doc for details. 25 | */ 26 | @NullMarked 27 | public class NegativeArraySizeException extends RuntimeException { 28 | 29 | public NegativeArraySizeException() { 30 | } 31 | 32 | public NegativeArraySizeException(@Nullable String message) { 33 | super(message); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/NoSuchFieldError.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package java.lang; 15 | 16 | import org.jspecify.annotations.NullMarked; 17 | 18 | /** Exists solely to make javac happy. */ 19 | @NullMarked 20 | class NoSuchFieldError {} 21 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/NullPointerException.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package java.lang 17 | 18 | import javaemul.lang.CauseHolder 19 | import javaemul.lang.InitCauseCapable 20 | 21 | open class NullPointerException(message: kotlin.String? = null) : 22 | kotlin.NullPointerException(message), InitCauseCapable { 23 | override val causeHolder = CauseHolder() 24 | override val cause 25 | get() = causeHolder.cause 26 | } 27 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/NumberFormatException.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package java.lang 17 | 18 | import javaemul.lang.CauseHolder 19 | import javaemul.lang.InitCauseCapable 20 | 21 | open class NumberFormatException(message: kotlin.String? = null) : 22 | kotlin.NumberFormatException(message), InitCauseCapable { 23 | override val causeHolder = CauseHolder() 24 | override val cause 25 | get() = causeHolder.cause 26 | } 27 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/OutOfMemoryError.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.lang 17 | 18 | typealias OutOfMemoryError = kotlin.OutOfMemoryError 19 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/Override.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.lang; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | /** 24 | * Indicates that a method definition is intended to override a declaration from 25 | * a superclass. [Sun 27 | * docs] 28 | */ 29 | @Target(ElementType.METHOD) 30 | @Retention(RetentionPolicy.SOURCE) 31 | public @interface Override { 32 | } 33 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/Readable.java: -------------------------------------------------------------------------------- 1 | /* Licensed to the Apache Software Foundation (ASF) under one or more 2 | * contributor license agreements. See the NOTICE file distributed with 3 | * this work for additional information regarding copyright ownership. 4 | * The ASF licenses this file to You under the Apache License, Version 2.0 5 | * (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package java.lang; 18 | 19 | import java.io.IOException; 20 | import java.nio.CharBuffer; 21 | import org.jspecify.annotations.NullMarked; 22 | 23 | /** 24 | * Represents a sequence of characters that can be incrementally read (copied) into a {@link 25 | * CharBuffer}. 26 | */ 27 | @NullMarked 28 | public interface Readable { 29 | int read(CharBuffer cb) throws IOException; 30 | } 31 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/Runnable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.lang; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** 21 | * Encapsulates an action for later execution. See the official Java API 23 | * doc for details. 24 | * 25 | *

This interface is provided only for JRE compatibility. GWT does not support multithreading. 26 | */ 27 | @FunctionalInterface 28 | @NullMarked 29 | public interface Runnable { 30 | void run(); 31 | } 32 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/RuntimeException.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package java.lang 17 | 18 | import javaemul.lang.CauseHolder 19 | import javaemul.lang.InitCauseCapable 20 | 21 | open class RuntimeException(message: kotlin.String? = null) : 22 | kotlin.RuntimeException(message), InitCauseCapable { 23 | override val causeHolder = CauseHolder() 24 | override val cause 25 | get() = causeHolder.cause 26 | 27 | constructor(message: kotlin.String?, cause: kotlin.Throwable?) : this(message) { 28 | initCause(cause) 29 | } 30 | 31 | constructor(cause: kotlin.Throwable?) : this(cause?.toString(), cause) 32 | } 33 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/SafeVarargs.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.lang; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Claims to the compiler that the annotation target does nothing potentially unsafe 26 | * to its varargs argument. 27 | */ 28 | @Documented 29 | @Retention(value = RetentionPolicy.RUNTIME) 30 | @Target(value = {ElementType.CONSTRUCTOR, ElementType.METHOD}) 31 | public @interface SafeVarargs { 32 | } 33 | 34 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/SecurityException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.lang; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** 21 | * See the 22 | * official Java API doc for details. 23 | * 24 | *

This exception is never thrown by GWT or GWT's libraries, as GWT does not have a 25 | * SecurityManager. It is provided in GWT only for compatibility with user code that explicitly 26 | * catches it. 27 | */ 28 | @NullMarked 29 | public class SecurityException extends RuntimeException { 30 | private SecurityException() { 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/Thread.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package java.lang; 17 | 18 | import javaemul.internal.annotations.KtNative; 19 | import org.jspecify.annotations.NullMarked; 20 | 21 | /** Thread subset supporting a threadId for simple logging and thread identity checks. */ 22 | @NullMarked 23 | @KtNative 24 | public final class Thread { 25 | 26 | public static native Thread currentThread(); 27 | 28 | private Thread() {} 29 | 30 | public native long getId(); 31 | 32 | public native String getName(); 33 | } 34 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/Void.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.lang; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | @NullMarked 21 | public final class Void { 22 | 23 | @SuppressWarnings("VoidMissingNullable") 24 | public static final Class TYPE = void.class; 25 | 26 | private Void() {} 27 | } 28 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/annotation/AnnotationFormatError.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.lang.annotation; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** 21 | * Indicates the annotation parser determined the annotation was malformed when reading from the 22 | * class file [Sun 24 | * docs]. 25 | */ 26 | @NullMarked 27 | public class AnnotationFormatError extends Error {} 28 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/annotation/AnnotationTypeMismatchException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.lang.annotation; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** 21 | * Indicates an attempt to access an element of an annotation that has changed since it was compiled 22 | * or serialized [Sun 24 | * docs]. 25 | */ 26 | @NullMarked 27 | public class AnnotationTypeMismatchException extends RuntimeException {} 28 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/annotation/Documented.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.lang.annotation; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** 21 | * Annotation which indicates annotations should be documented by javadoc/etc [Sun 23 | * docs]. 24 | */ 25 | @Documented 26 | @Retention(RetentionPolicy.RUNTIME) 27 | @Target(ElementType.ANNOTATION_TYPE) 28 | @NullMarked 29 | public @interface Documented {} 30 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/annotation/ElementType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.lang.annotation; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** 21 | * Enumerates types of declared elements in a Java program [Oracle 23 | * docs]. 24 | */ 25 | @NullMarked 26 | public enum ElementType { 27 | ANNOTATION_TYPE, CONSTRUCTOR, FIELD, LOCAL_VARIABLE, METHOD, PACKAGE, 28 | PARAMETER, TYPE, TYPE_PARAMETER, TYPE_USE, 29 | } 30 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/annotation/Inherited.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.lang.annotation; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** 21 | * Annotation which indicates an annotation type is automatically inherited [Sun 23 | * docs]. 24 | */ 25 | @Documented 26 | @Retention(RetentionPolicy.RUNTIME) 27 | @Target(ElementType.ANNOTATION_TYPE) 28 | @NullMarked 29 | public @interface Inherited {} 30 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/annotation/Native.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.lang.annotation; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** 21 | * Indicates that a field defining a constant value may be referenced from native code. [Oracle 23 | * docs] 24 | */ 25 | @Documented 26 | @Target(ElementType.FIELD) 27 | @Retention(RetentionPolicy.SOURCE) 28 | @NullMarked 29 | public @interface Native {} 30 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/annotation/Repeatable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.lang.annotation; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** 21 | * Indicates that the annotation type whose declaration it (meta-)annotates is repeatable. [Oracle 23 | * docs] 24 | */ 25 | @Documented 26 | @Target(ElementType.ANNOTATION_TYPE) 27 | @Retention(RetentionPolicy.RUNTIME) 28 | @NullMarked 29 | public @interface Repeatable { 30 | Class value(); 31 | } 32 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/annotation/Retention.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.lang.annotation; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** 21 | * Annotation which indicates how long annotations should be retained [Sun doc]. 23 | */ 24 | @Documented 25 | @Retention(RetentionPolicy.RUNTIME) 26 | @Target(ElementType.ANNOTATION_TYPE) 27 | @NullMarked 28 | public @interface Retention { 29 | RetentionPolicy value(); 30 | } 31 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/annotation/RetentionPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.lang.annotation; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** 21 | * Enumerates annotation retention policies [Sun 23 | * docs]. 24 | */ 25 | @NullMarked 26 | public enum RetentionPolicy { 27 | CLASS, RUNTIME, SOURCE, 28 | } 29 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/annotation/Target.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.lang.annotation; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** 21 | * Annotation which indicates the kinds of program element to which an annotation type is applicable 22 | * [Sun 23 | * docs]. 24 | */ 25 | @Documented 26 | @Retention(RetentionPolicy.RUNTIME) 27 | @Target(ElementType.ANNOTATION_TYPE) 28 | @NullMarked 29 | public @interface Target { 30 | ElementType[] value(); 31 | } 32 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/invoke/CallSite.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package java.lang.invoke; 15 | 16 | /** Exists solely to make javac happy. */ 17 | public class CallSite {} 18 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/invoke/MethodHandle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package java.lang.invoke; 15 | 16 | /** Exists solely to make javac happy. */ 17 | class MethodHandle {} 18 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/invoke/MethodHandles.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package java.lang.invoke; 15 | 16 | /** Exists solely to make javac happy. */ 17 | class MethodHandles { 18 | static class Lookup {} 19 | } 20 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/invoke/MethodType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package java.lang.invoke; 15 | 16 | /** Exists solely to make javac happy. */ 17 | class MethodType {} 18 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/ref/WeakReference.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package java.lang.ref 18 | 19 | import kotlin.native.ref.WeakReference as KotlinWeakReference 20 | 21 | typealias WeakReference = KotlinWeakReference 22 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/lang/reflect/Type.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.lang.reflect; 17 | 18 | /** 19 | * This interface makes {@link java.lang.reflect.Type} available to GWT clients. 20 | * 21 | * @see java.lang.reflect.Type 22 | */ 23 | public interface Type { 24 | 25 | // just a marker interface. 26 | 27 | } 28 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/net/HttpDate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package java.net; 18 | 19 | import java.util.Date; 20 | import javaemul.internal.annotations.KtNative; 21 | import org.jspecify.annotations.NullMarked; 22 | import org.jspecify.annotations.Nullable; 23 | 24 | /** Best-effort parser for HTTP dates. */ 25 | @NullMarked 26 | @KtNative 27 | final class HttpDate { 28 | 29 | /** Returns the date for {@code value}. Returns null if the value couldn't be parsed. */ 30 | public static native @Nullable Date parse(String value); 31 | } 32 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/net/InetUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.net; 17 | 18 | import javaemul.internal.annotations.KtNative; 19 | import org.jspecify.annotations.NullMarked; 20 | 21 | /** JRE-internal utility functions for working with IPv4 and IPv6 addresses. */ 22 | @NullMarked 23 | @KtNative 24 | final class InetUtil { 25 | public static native boolean isValidIpv4Address(String address); 26 | 27 | public static native boolean isValidIpv6Address(String address); 28 | 29 | private InetUtil() {} 30 | } 31 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/nio/KotlinNativePlatform.java: -------------------------------------------------------------------------------- 1 | /* Licensed to the Apache Software Foundation (ASF) under one or more 2 | * contributor license agreements. See the NOTICE file distributed with 3 | * this work for additional information regarding copyright ownership. 4 | * The ASF licenses this file to You under the Apache License, Version 2.0 5 | * (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package java.nio; 18 | 19 | import javaemul.internal.annotations.KtNative; 20 | 21 | /** Helper class for ByteOrder compilation */ 22 | @KtNative(name = "kotlin.native.Platform") 23 | public final class KotlinNativePlatform { 24 | public static boolean isLittleEndian; 25 | } 26 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/nio/charset/CharsetEncoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.nio.charset; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** Placeholder class used in stub method declarations that need to match the real JRE. */ 21 | @NullMarked 22 | public abstract class CharsetEncoder { 23 | 24 | public abstract boolean canEncode(char c); 25 | 26 | public boolean canEncode(String s) { 27 | for (int i = 0; i < s.length(); i++) { 28 | if (!canEncode(s.charAt(i))) { 29 | return false; 30 | } 31 | } 32 | return true; 33 | } 34 | 35 | public abstract Charset charset(); 36 | } 37 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/nio/charset/IllegalCharsetNameException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package java.nio.charset; 18 | 19 | /** 20 | * GWT emulation of {@link IllegalCharsetNameException}. 21 | */ 22 | public class IllegalCharsetNameException extends IllegalArgumentException { 23 | private final String charsetName; 24 | 25 | public IllegalCharsetNameException(String charsetName) { 26 | super(String.valueOf(charsetName)); 27 | this.charsetName = charsetName; 28 | } 29 | 30 | public String getCharsetName() { 31 | return charsetName; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/nio/charset/StandardCharsets.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.nio.charset; 17 | 18 | import javaemul.internal.EmulatedCharset; 19 | import org.jspecify.annotations.NullMarked; 20 | 21 | /** Partial emulation of the corresponding JRE-Class */ 22 | @NullMarked 23 | public final class StandardCharsets { 24 | 25 | public static final Charset ISO_8859_1 = EmulatedCharset.ISO_8859_1; 26 | public static final Charset US_ASCII = EmulatedCharset.US_ASCII; 27 | public static final Charset UTF_8 = EmulatedCharset.UTF_8; 28 | 29 | private StandardCharsets() {} 30 | } 31 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/nio/charset/UnsupportedCharsetException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package java.nio.charset; 18 | 19 | /** 20 | * GWT emulation of {@link UnsupportedCharsetException}. 21 | */ 22 | public class UnsupportedCharsetException extends IllegalArgumentException { 23 | private final String charsetName; 24 | 25 | public UnsupportedCharsetException(String charsetName) { 26 | super(String.valueOf(charsetName)); 27 | this.charsetName = charsetName; 28 | } 29 | 30 | public String getCharsetName() { 31 | return charsetName; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/nio/file/Path.java: -------------------------------------------------------------------------------- 1 | /* Licensed to the Apache Software Foundation (ASF) under one or more 2 | * contributor license agreements. See the NOTICE file distributed with 3 | * this work for additional information regarding copyright ownership. 4 | * The ASF licenses this file to You under the Apache License, Version 2.0 5 | * (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package java.nio.file; 18 | 19 | /** 20 | * See the official Java 21 | * API doc for details. 22 | * 23 | *

{@code Path} is not supported under J2KT, but the class needs to exist because it appears in 24 | * Truth's API. 25 | */ 26 | interface Path {} 27 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/security/DigestException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.security; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | import org.jspecify.annotations.Nullable; 20 | 21 | /** 22 | * A generic security exception type - [Sun's 24 | * docs]. 25 | */ 26 | @NullMarked 27 | public class DigestException extends GeneralSecurityException { 28 | 29 | public DigestException() { 30 | } 31 | 32 | public DigestException(@Nullable String msg) { 33 | super(msg); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/security/NoSuchAlgorithmException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.security; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | import org.jspecify.annotations.Nullable; 20 | 21 | /** 22 | * A generic security exception type - [Sun's 24 | * docs]. 25 | */ 26 | @NullMarked 27 | public class NoSuchAlgorithmException extends GeneralSecurityException { 28 | 29 | public NoSuchAlgorithmException() { 30 | } 31 | 32 | public NoSuchAlgorithmException(@Nullable String msg) { 33 | super(msg); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/security/SecureRandom.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.security; 17 | 18 | import java.util.Random; 19 | import javaemul.internal.annotations.KtNative; 20 | import org.jspecify.annotations.NullMarked; 21 | 22 | /** 23 | * Secure random number generator. 24 | * 25 | *

SecureRandom.kt where passes the randomization into to iOS random number generator. 26 | */ 27 | @KtNative 28 | @NullMarked 29 | public final class SecureRandom extends Random { 30 | public SecureRandom() {} 31 | 32 | public SecureRandom(byte[] seed) {} 33 | } 34 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/security/spec/AlgorithmParameterSpec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package java.security.spec; 19 | 20 | import org.jspecify.annotations.NullMarked; 21 | 22 | /** 23 | * The marker interface for algorithm parameter specifications. The purpose is to group parameter 24 | * specifications for algorithms. 25 | */ 26 | @NullMarked 27 | public interface AlgorithmParameterSpec {} 28 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/security/spec/KeySpec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package java.security.spec; 19 | 20 | import org.jspecify.annotations.NullMarked; 21 | 22 | /** 23 | * The marker interface for key specifications. The purpose is to group key specifications for 24 | * cryptographic keys. 25 | */ 26 | @NullMarked 27 | public interface KeySpec {} 28 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/text/ParseException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package java.text; 18 | 19 | import org.jspecify.annotations.NullMarked; 20 | import org.jspecify.annotations.Nullable; 21 | 22 | /** Emulation of {@code java.text.ParseException}. */ 23 | @NullMarked 24 | public class ParseException extends Exception { 25 | 26 | private final int errorOffset; 27 | 28 | public ParseException(@Nullable String s, int errorOffset) { 29 | super(s); 30 | this.errorOffset = errorOffset; 31 | } 32 | 33 | public int getErrorOffset() { 34 | return errorOffset; 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/AbstractCollection.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util 17 | 18 | import javaemul.internal.CollectionHelper 19 | 20 | abstract class AbstractCollection : AbstractMutableCollection(), Collection { 21 | override fun add(e: E): Boolean = throw UnsupportedOperationException() 22 | 23 | override fun toArray(): Array = CollectionHelper.toArray(this) 24 | 25 | override fun toArray(a: Array): Array = CollectionHelper.toArray(this, a) 26 | } 27 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/AbstractSet.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util 17 | 18 | import javaemul.internal.CollectionHelper 19 | 20 | abstract class AbstractSet : AbstractMutableSet(), Set { 21 | override fun add(element: E): Boolean { 22 | throw UnsupportedOperationException() 23 | } 24 | 25 | override fun toArray(): Array = CollectionHelper.toArray(this) 26 | 27 | override fun toArray(a: Array): Array = CollectionHelper.toArray(this, a) 28 | } 29 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/ConcurrentModificationException.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package java.util 17 | 18 | import javaemul.lang.CauseHolder 19 | import javaemul.lang.InitCauseCapable 20 | 21 | open class ConcurrentModificationException(message: String? = null) : 22 | kotlin.ConcurrentModificationException(message), InitCauseCapable { 23 | override val causeHolder = CauseHolder() 24 | override val cause 25 | get() = causeHolder.cause 26 | 27 | constructor(message: String?, cause: kotlin.Throwable?) : this(message) { 28 | initCause(cause) 29 | } 30 | 31 | constructor(cause: kotlin.Throwable?) : this(cause?.toString(), cause) 32 | } 33 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/EmptyStackException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** 21 | * See the 22 | * official Java API doc for details. 23 | */ 24 | @NullMarked 25 | public class EmptyStackException extends RuntimeException {} 26 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/Enumeration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | import org.jspecify.annotations.Nullable; 20 | 21 | /** 22 | * An interface to generate a series of elements, one at a time. [Sun docs] 24 | * 25 | * @param the type being enumerated. 26 | */ 27 | @NullMarked 28 | public interface Enumeration { 29 | 30 | boolean hasMoreElements(); 31 | 32 | E nextElement(); 33 | } 34 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/EventListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** 21 | * A tag interface that other "listener" interfaces can extend to indicate their adherence to the 22 | * observer pattern. 23 | */ 24 | @NullMarked 25 | public interface EventListener {} 26 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/EventObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** Available as a superclass of event objects. */ 21 | @NullMarked 22 | public class EventObject { 23 | 24 | protected transient Object source; 25 | 26 | public EventObject(Object source) { 27 | this.source = source; 28 | } 29 | 30 | public Object getSource() { 31 | return source; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/Iterator.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util 17 | 18 | import java.util.function.Consumer 19 | 20 | interface Iterator : MutableIterator { 21 | fun forEachRemaining(consumer: Consumer) { 22 | forEach(consumer::accept) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/LinkedHashMap.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package java.util 18 | 19 | import kotlin.Cloneable 20 | 21 | // Note: This implementation relies on the fact that Kotlin Native's HashMap is linked. 22 | open class LinkedHashMap : HashMap, MutableMap, Cloneable { 23 | constructor() : super() 24 | 25 | constructor(initialCapacity: Int) : super(initialCapacity) 26 | 27 | constructor(initialCapacity: Int, loadFactor: Float) : super(initialCapacity, loadFactor) 28 | 29 | constructor(original: MutableMap) : super(original) 30 | 31 | override fun clone(): Any = LinkedHashMap(this) 32 | } 33 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/List.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util 17 | 18 | import java.util.function.UnaryOperator 19 | import kotlin.Comparator as KotlinComparator 20 | import kotlin.collections.replaceAll as kotlinReplaceAll 21 | 22 | interface List : MutableList, Collection { 23 | fun replaceAll(operator: UnaryOperator): Unit = kotlinReplaceAll(operator::apply) 24 | 25 | fun sort(c: KotlinComparator?): Unit = 26 | if (c == null) sortBy { it as Comparable } else sortWith(c) 27 | } 28 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/NoSuchElementException.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package java.util 17 | 18 | import javaemul.lang.CauseHolder 19 | import javaemul.lang.InitCauseCapable 20 | 21 | open class NoSuchElementException(message: String? = null) : 22 | kotlin.NoSuchElementException(message), InitCauseCapable { 23 | override val causeHolder = CauseHolder() 24 | override val cause 25 | get() = causeHolder.cause 26 | } 27 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/Queue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | import org.jspecify.annotations.Nullable; 20 | 21 | /** 22 | * A collection designed for holding elements prior to processing. [Sun docs] 24 | * 25 | * @param element type. 26 | */ 27 | @NullMarked 28 | public interface Queue extends Collection { 29 | 30 | E element(); 31 | 32 | boolean offer(E o); 33 | 34 | @Nullable E peek(); 35 | 36 | @Nullable E poll(); 37 | 38 | E remove(); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/RandomAccess.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util; 17 | 18 | import javaemul.internal.annotations.KtNative; 19 | import org.jspecify.annotations.NullMarked; 20 | 21 | /** 22 | * Indicates that a data structure supports constant-time random access to its contained objects. 23 | */ 24 | @KtNative(name = "kotlin.collections.RandomAccess") 25 | @NullMarked 26 | public interface RandomAccess {} 27 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/ReadonlyCollection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util; 17 | 18 | import javaemul.internal.annotations.KtNative; 19 | import javaemul.internal.annotations.KtOut; 20 | import org.jspecify.annotations.NullMarked; 21 | import org.jspecify.annotations.Nullable; 22 | 23 | /** 24 | * Representation of the readonly Kotlin collection interface. Only for use by the JRE emulation. 25 | */ 26 | @KtNative(name = "kotlin.collections.Collection") 27 | @NullMarked 28 | interface ReadonlyCollection<@KtOut E extends @Nullable Object> { 29 | // Methods omitted (type is only used in native method parameter/return types). 30 | } 31 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/ReadonlyMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util; 17 | 18 | import javaemul.internal.annotations.KtNative; 19 | import javaemul.internal.annotations.KtOut; 20 | import org.jspecify.annotations.NullMarked; 21 | import org.jspecify.annotations.Nullable; 22 | 23 | /** Representation of the readonly Kotlin map interface. Only for use by the JRE emulation. */ 24 | @KtNative(name = "kotlin.collections.Map") 25 | @NullMarked 26 | public interface ReadonlyMap { 27 | // Methods omitted (type is only used in native method parameter/return types). 28 | } 29 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/Set.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util 17 | 18 | interface Set : MutableSet, Collection {} 19 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/TooManyListenersException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2006 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | import org.jspecify.annotations.Nullable; 20 | 21 | /** Thrown when the subject of an observer cannot support additional observers. */ 22 | @NullMarked 23 | public class TooManyListenersException extends Exception { 24 | 25 | public TooManyListenersException() { 26 | } 27 | 28 | public TooManyListenersException(@Nullable String message) { 29 | super(message); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/concurrent/Callable.java: -------------------------------------------------------------------------------- 1 | // CHECKSTYLE_OFF: Copyrighted to Guava Authors. 2 | /* 3 | * Copyright (C) 2011 The Guava Authors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | // CHECKSTYLE_ON 18 | 19 | package java.util.concurrent; 20 | 21 | import org.jspecify.annotations.NullMarked; 22 | import org.jspecify.annotations.Nullable; 23 | 24 | /** 25 | * Emulation of Callable. 26 | * 27 | * @param result of call 28 | */ 29 | @NullMarked 30 | public interface Callable { 31 | V call() throws Exception; 32 | } 33 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/concurrent/CancellationException.java: -------------------------------------------------------------------------------- 1 | // CHECKSTYLE_OFF: Copyrighted to Guava Authors. 2 | /* 3 | * Copyright (C) 2015 The Guava Authors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | // CHECKSTYLE_ON 18 | 19 | package java.util.concurrent; 20 | 21 | import org.jspecify.annotations.NullMarked; 22 | import org.jspecify.annotations.Nullable; 23 | 24 | /** Emulation of CancellationException. */ 25 | @NullMarked 26 | public class CancellationException extends IllegalStateException { 27 | 28 | public CancellationException() { } 29 | 30 | public CancellationException(@Nullable String message) { 31 | super(message); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/concurrent/Delayed.java: -------------------------------------------------------------------------------- 1 | // CHECKSTYLE_OFF: Copyrighted to members of JCP JSR-166 Expert Group. 2 | /* 3 | * This file is a modified version of 4 | * http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/main/java/util/concurrent/Delayed.java?revision=1.11 5 | * which contained the following notice: 6 | * 7 | * Written by Doug Lea with assistance from members of JCP JSR-166 8 | * Expert Group and released to the public domain, as explained at 9 | * http://creativecommons.org/publicdomain/zero/1.0/ 10 | */ 11 | // CHECKSTYLE_ON 12 | 13 | package java.util.concurrent; 14 | 15 | import org.jspecify.annotations.NullMarked; 16 | 17 | /** Emulation of Delayed. */ 18 | @NullMarked 19 | public interface Delayed extends Comparable { 20 | long getDelay(TimeUnit unit); 21 | } 22 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/concurrent/Executor.java: -------------------------------------------------------------------------------- 1 | // CHECKSTYLE_OFF: Copyrighted to Guava Authors. 2 | /* 3 | * Copyright (C) 2015 The Guava Authors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | // CHECKSTYLE_ON 18 | 19 | package java.util.concurrent; 20 | 21 | import org.jspecify.annotations.NullMarked; 22 | 23 | /** Emulation of Executor. */ 24 | @NullMarked 25 | public interface Executor { 26 | void execute(Runnable command); 27 | } 28 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/concurrent/RunnableFuture.java: -------------------------------------------------------------------------------- 1 | // CHECKSTYLE_OFF: Copyrighted to Guava Authors. 2 | /* 3 | * Copyright (C) 2015 The Guava Authors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | // CHECKSTYLE_ON 18 | 19 | package java.util.concurrent; 20 | 21 | import org.jspecify.annotations.NullMarked; 22 | import org.jspecify.annotations.Nullable; 23 | 24 | /** 25 | * Emulation of RunnableFuture. 26 | * 27 | * @param value type returned by the future. 28 | */ 29 | @NullMarked 30 | public interface RunnableFuture extends Runnable, Future {} 31 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/concurrent/ScheduledFuture.java: -------------------------------------------------------------------------------- 1 | // CHECKSTYLE_OFF: Copyrighted to members of JCP JSR-166 Expert Group. 2 | /* 3 | * This file is a modified version of 4 | * http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/main/java/util/concurrent/ScheduledFuture.java?revision=1.6 5 | * which contained the following notice: 6 | * 7 | * Written by Doug Lea with assistance from members of JCP JSR-166 8 | * Expert Group and released to the public domain, as explained at 9 | * http://creativecommons.org/publicdomain/zero/1.0/ 10 | */ 11 | // CHECKSTYLE_ON 12 | 13 | package java.util.concurrent; 14 | 15 | import org.jspecify.annotations.NullMarked; 16 | import org.jspecify.annotations.Nullable; 17 | 18 | /** 19 | * Emulation of ScheduleFuture. 20 | * 21 | * @param value type returned by the future. 22 | */ 23 | @NullMarked 24 | public interface ScheduledFuture extends Delayed, Future {} 25 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/concurrent/TimeoutException.java: -------------------------------------------------------------------------------- 1 | // CHECKSTYLE_OFF: Copyrighted to Guava Authors. 2 | /* 3 | * Copyright (C) 2015 The Guava Authors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | // CHECKSTYLE_ON 18 | 19 | package java.util.concurrent; 20 | 21 | import org.jspecify.annotations.NullMarked; 22 | import org.jspecify.annotations.Nullable; 23 | 24 | /** Emulation of TimeoutException. */ 25 | @NullMarked 26 | public class TimeoutException extends Exception { 27 | public TimeoutException() { } 28 | 29 | public TimeoutException(@Nullable String message) { 30 | super(message); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/concurrent/locks/Lock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package java.util.concurrent.locks; 15 | 16 | /** Partial emulation of Lock. */ 17 | public interface Lock { 18 | 19 | void lock(); 20 | 21 | void unlock(); 22 | } 23 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/concurrent/locks/ReentrantLock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package java.util.concurrent.locks; 15 | 16 | import javaemul.internal.annotations.KtNative; 17 | 18 | /** Partial emulation of ReentrantLock. */ 19 | @KtNative 20 | public final class ReentrantLock implements Lock { 21 | 22 | @Override 23 | public native void lock(); 24 | 25 | @Override 26 | public native void unlock(); 27 | } 28 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/concurrent/locks/ReentrantLock.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package java.util.concurrent.locks 15 | 16 | import javaemul.lang.J2ktMonitor 17 | 18 | /** Implementation of ReentrantLock used in Kotlin Native. */ 19 | class ReentrantLock : Lock, J2ktMonitor() {} 20 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/function/BooleanSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util.function; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** 21 | * See 22 | * the official Java API doc for details. 23 | */ 24 | @FunctionalInterface 25 | @NullMarked 26 | public interface BooleanSupplier { 27 | 28 | boolean getAsBoolean(); 29 | } 30 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/function/DoubleBinaryOperator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util.function; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** 21 | * See the 23 | * official Java API doc for details. 24 | */ 25 | @FunctionalInterface 26 | @NullMarked 27 | public interface DoubleBinaryOperator { 28 | 29 | double applyAsDouble(double left, double right); 30 | } 31 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/function/DoubleFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util.function; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | import org.jspecify.annotations.Nullable; 20 | 21 | /** 22 | * See 23 | * the official Java API doc for details. 24 | * 25 | * @param type of the return value 26 | */ 27 | @FunctionalInterface 28 | @NullMarked 29 | public interface DoubleFunction { 30 | 31 | R apply(double value); 32 | } 33 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/function/DoubleSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util.function; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** 21 | * See 22 | * the official Java API doc for details. 23 | */ 24 | @FunctionalInterface 25 | @NullMarked 26 | public interface DoubleSupplier { 27 | 28 | double getAsDouble(); 29 | } 30 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/function/DoubleToIntFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util.function; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** 21 | * See the 23 | * official Java API doc for details. 24 | */ 25 | @FunctionalInterface 26 | @NullMarked 27 | public interface DoubleToIntFunction { 28 | 29 | int applyAsInt(double value); 30 | } 31 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/function/DoubleToLongFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util.function; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** 21 | * See the 23 | * official Java API doc for details. 24 | */ 25 | @FunctionalInterface 26 | @NullMarked 27 | public interface DoubleToLongFunction { 28 | 29 | long applyAsLong(double value); 30 | } 31 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/function/IntBinaryOperator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util.function; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** 21 | * See the 23 | * official Java API doc for details. 24 | */ 25 | @FunctionalInterface 26 | @NullMarked 27 | public interface IntBinaryOperator { 28 | 29 | int applyAsInt(int left, int right); 30 | } 31 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/function/IntFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util.function; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | import org.jspecify.annotations.Nullable; 20 | 21 | /** 22 | * See the 23 | * official Java API doc for details. 24 | * 25 | * @param type of the return value 26 | */ 27 | @FunctionalInterface 28 | @NullMarked 29 | public interface IntFunction { 30 | 31 | R apply(int value); 32 | } 33 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/function/IntSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util.function; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** 21 | * See the 22 | * official Java API doc for details. 23 | */ 24 | @FunctionalInterface 25 | @NullMarked 26 | public interface IntSupplier { 27 | 28 | int getAsInt(); 29 | } 30 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/function/IntToDoubleFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util.function; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** 21 | * See the 23 | * official Java API doc for details. 24 | */ 25 | @FunctionalInterface 26 | @NullMarked 27 | public interface IntToDoubleFunction { 28 | 29 | double applyAsDouble(int value); 30 | } 31 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/function/IntToLongFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util.function; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** 21 | * See the 23 | * official Java API doc for details. 24 | */ 25 | @FunctionalInterface 26 | @NullMarked 27 | public interface IntToLongFunction { 28 | 29 | long applyAsLong(int value); 30 | } 31 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/function/LongBinaryOperator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util.function; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** 21 | * See the 23 | * official Java API doc for details. 24 | */ 25 | @FunctionalInterface 26 | @NullMarked 27 | public interface LongBinaryOperator { 28 | 29 | long applyAsLong(long left, long right); 30 | } 31 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/function/LongFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util.function; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | import org.jspecify.annotations.Nullable; 20 | 21 | /** 22 | * See the 23 | * official Java API doc for details. 24 | * 25 | * @param type of the return value 26 | */ 27 | @FunctionalInterface 28 | @NullMarked 29 | public interface LongFunction { 30 | 31 | R apply(long value); 32 | } 33 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/function/LongSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util.function; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** 21 | * See the 22 | * official Java API doc for details. 23 | */ 24 | @FunctionalInterface 25 | @NullMarked 26 | public interface LongSupplier { 27 | 28 | long getAsLong(); 29 | } 30 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/function/LongToDoubleFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util.function; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** 21 | * See the 23 | * official Java API doc for details. 24 | */ 25 | @FunctionalInterface 26 | @NullMarked 27 | public interface LongToDoubleFunction { 28 | 29 | double applyAsDouble(long value); 30 | } 31 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/function/LongToIntFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util.function; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | 20 | /** 21 | * See the 23 | * official Java API doc for details. 24 | */ 25 | @FunctionalInterface 26 | @NullMarked 27 | public interface LongToIntFunction { 28 | 29 | int applyAsInt(long value); 30 | } 31 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/function/ObjDoubleConsumer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util.function; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | import org.jspecify.annotations.Nullable; 20 | 21 | /** 22 | * See the 24 | * official Java API doc for details. 25 | * 26 | * @param type of the object argument 27 | */ 28 | @FunctionalInterface 29 | @NullMarked 30 | public interface ObjDoubleConsumer { 31 | 32 | void accept(T t, double value); 33 | } 34 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/function/ObjIntConsumer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util.function; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | import org.jspecify.annotations.Nullable; 20 | 21 | /** 22 | * See 23 | * the official Java API doc for details. 24 | * 25 | * @param type of the object argument 26 | */ 27 | @FunctionalInterface 28 | @NullMarked 29 | public interface ObjIntConsumer { 30 | 31 | void accept(T t, int value); 32 | } 33 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/function/ObjLongConsumer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util.function; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | import org.jspecify.annotations.Nullable; 20 | 21 | /** 22 | * See 23 | * the official Java API doc for details. 24 | * 25 | * @param type of the object argument 26 | */ 27 | @FunctionalInterface 28 | @NullMarked 29 | public interface ObjLongConsumer { 30 | 31 | void accept(T t, long value); 32 | } 33 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/function/Supplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util.function; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | import org.jspecify.annotations.Nullable; 20 | 21 | /** 22 | * See the 23 | * official Java API doc for details. 24 | * 25 | * @param type of the supplied value 26 | */ 27 | @FunctionalInterface 28 | @NullMarked 29 | public interface Supplier { 30 | 31 | T get(); 32 | } 33 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/function/ToDoubleFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util.function; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | import org.jspecify.annotations.Nullable; 20 | 21 | /** 22 | * See 23 | * the official Java API doc for details. 24 | * 25 | * @param type of the argument 26 | */ 27 | @FunctionalInterface 28 | @NullMarked 29 | public interface ToDoubleFunction { 30 | 31 | double applyAsDouble(T value); 32 | } 33 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/function/ToIntFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util.function; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | import org.jspecify.annotations.Nullable; 20 | 21 | /** 22 | * See the 23 | * official Java API doc for details. 24 | * 25 | * @param type of the argument 26 | */ 27 | @FunctionalInterface 28 | @NullMarked 29 | public interface ToIntFunction { 30 | 31 | int applyAsInt(T value); 32 | } 33 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/function/ToLongFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package java.util.function; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | import org.jspecify.annotations.Nullable; 20 | 21 | /** 22 | * See 23 | * the official Java API doc for details. 24 | * 25 | * @param type of the argument 26 | */ 27 | @FunctionalInterface 28 | @NullMarked 29 | public interface ToLongFunction { 30 | 31 | long applyAsLong(T value); 32 | } 33 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/java/util/zip/NativeZipStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package java.util.zip; 18 | 19 | import javaemul.internal.annotations.KtNative; 20 | import org.jspecify.annotations.NullMarked; 21 | 22 | @NullMarked 23 | @KtNative 24 | final class NativeZipStream { 25 | // Type is opaque to Java. 26 | } 27 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/javaemul/internal/ArrayHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.internal; 17 | 18 | import org.jspecify.annotations.NullMarked; 19 | import org.jspecify.annotations.Nullable; 20 | 21 | @NullMarked 22 | public final class ArrayHelper { 23 | 24 | @SuppressWarnings("unchecked") 25 | public static @Nullable T[] createFrom(T[] array, int newLength) { 26 | // This works because the code only runs on Kotlin Native and not on the JVM. 27 | return (T[]) new Object[newLength]; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/javaemul/internal/DebugDefine.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.internal; 17 | 18 | import javaemul.internal.annotations.KtNative; 19 | import javaemul.internal.annotations.KtProperty; 20 | 21 | /** Exposes the "DEBUG" #define to Java / Kotlin */ 22 | @KtNative 23 | public final class DebugDefine { 24 | 25 | @KtProperty 26 | public static native boolean getValue(); 27 | 28 | private DebugDefine() {} 29 | } 30 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/javaemul/internal/DebugDefine.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.internal 17 | 18 | import kotlinx.cinterop.ExperimentalForeignApi 19 | import third_party.java_src.xplat.j2kt.jre.java_debug_define.DEBUG_MODE 20 | 21 | object DebugDefine { 22 | @OptIn(ExperimentalForeignApi::class) const val value: Boolean = DEBUG_MODE != 0 23 | } 24 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/javaemul/internal/KtNativeUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.internal; 17 | 18 | import javaemul.internal.annotations.KtNative; 19 | 20 | @KtNative 21 | public final class KtNativeUtils { 22 | public static native T ktNative(); 23 | } 24 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/javaemul/internal/debug_define.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2025 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | #ifndef THIRD_PARTY_JAVA_SRC_XPLAT_J2KT_JRE_JAVA_NATIVE_JAVA_LANG_DEBUG_H_ 17 | #define THIRD_PARTY_JAVA_SRC_XPLAT_J2KT_JRE_JAVA_NATIVE_JAVA_LANG_DEBUG_H_ 18 | 19 | // Expose the DEBUG flag to cinterop 20 | 21 | #ifdef DEBUG 22 | #define DEBUG_MODE 1 23 | #else 24 | #define DEBUG_MODE 0 25 | #endif 26 | 27 | #endif // THIRD_PARTY_JAVA_SRC_XPLAT_J2KT_JRE_JAVA_NATIVE_JAVA_LANG_DEBUG_H_ 28 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/javaemul/lang/CauseHolder.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package javaemul.lang 17 | 18 | import javaemul.internal.InternalPreconditions.Companion.checkState 19 | 20 | class CauseHolder() { 21 | // Holds the cause (a Throwable or null), or this, if no cause was set 22 | private var thisOrCause: Any? = this 23 | 24 | var cause: Throwable? 25 | get() = if (hasCause()) thisOrCause as Throwable? else null 26 | set(value: Throwable?) { 27 | checkState(!hasCause(), "Can't overwrite cause") 28 | thisOrCause = value 29 | } 30 | 31 | private fun hasCause(): Boolean = thisOrCause !== this 32 | } 33 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/javaemul/lang/MutableCollectionJvm.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.lang 17 | 18 | /** A KMP subtype of MutableCollection with all the additional methods of JVM's MutableCollection */ 19 | typealias MutableCollectionJvm = java.util.Collection 20 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/javaemul/lang/MutableIterableJvm.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.lang 17 | 18 | /** A KMP subtype of MutableIterable with all the additional methods of JVM's MutableIterable */ 19 | typealias MutableIterableJvm = java.lang.Iterable 20 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/javaemul/lang/MutableIteratorJvm.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.lang 17 | 18 | /** A KMP subtype of MutableIterator with all the additional methods of JVM's MutableIterator */ 19 | typealias MutableIteratorJvm = java.util.Iterator 20 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/javaemul/lang/MutableListJvm.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.lang 17 | 18 | /** A KMP subtype of MutableList with all the additional methods of JVM's MutableList */ 19 | typealias MutableListJvm = java.util.List 20 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/javaemul/lang/MutableMapJvm.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.lang 17 | 18 | /** A KMP subtype of MutableMap with all the additional methods of JVM's MutableMap */ 19 | typealias MutableMapJvm = java.util.Map 20 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/javaemul/lang/MutableSetJvm.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.lang 17 | 18 | /** A KMP subtype of MutableSet with all the additional methods of JVM's MutableSet */ 19 | typealias MutableSetJvm = java.util.Set 20 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/javaemul/lang/NativeThrows.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.lang 17 | 18 | /* 19 | * On Kotlin Native, the [NativeThrows] annotations maps to [kotlin.Throws]. On other platforms it's 20 | * ignored.

21 | * 22 | * We have the indirection with different typealiases on different platforms here because we cannot 23 | * use [kotlin.Throws] in the transpiler output directly. We need different class lists on different 24 | * platforms (because of https://youtrack.jetbrains.com/issue/KT-60731/). 25 | */ 26 | typealias NativeThrows = Throws 27 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/javaemul/lang/ThrowableJvm.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package javaemul.lang 17 | 18 | /** KMP version of Throwable with the additional methods of Throwable from Kotlin/JVM */ 19 | typealias ThrowableJvm = java.lang.Throwable 20 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/javaemul/lang/iteratorExtensions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package javaemul.lang 17 | 18 | import java.util.Iterator as JavaUtilIterator 19 | import java.util.function.Consumer 20 | 21 | fun Iterator.forEachRemaining(consumer: Consumer) { 22 | if (this is JavaUtilIterator) { 23 | (this as JavaUtilIterator).forEachRemaining(consumer) 24 | } else { 25 | forEach(consumer::accept) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/kotlin/Cloneable.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package kotlin 17 | 18 | /** Indicates that a class implements clone(). */ 19 | typealias Cloneable = java.lang.Cloneable 20 | -------------------------------------------------------------------------------- /j2kt/jre/java/native/kotlin/jvm/Throws.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package kotlin.jvm 17 | 18 | import kotlin.reflect.KClass 19 | 20 | @Target( 21 | AnnotationTarget.FUNCTION, 22 | AnnotationTarget.PROPERTY_GETTER, 23 | AnnotationTarget.PROPERTY_SETTER, 24 | AnnotationTarget.CONSTRUCTOR 25 | ) 26 | @Retention(AnnotationRetention.SOURCE) 27 | annotation class Throws(vararg val exceptionClasses: KClass) 28 | -------------------------------------------------------------------------------- /j2kt/jre/javatests/interop/ImpliedPropertyNameTest.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package interop 17 | 18 | import com.google.common.truth.Truth.assertThat 19 | import org.junit.Test 20 | import org.junit.runner.RunWith 21 | import org.junit.runners.JUnit4 22 | 23 | @RunWith(JUnit4::class) 24 | class ImpliedPropertyNameTest { 25 | 26 | val javaGetters = JavaGetters() 27 | 28 | @Test 29 | fun getIf_impliedPropertyNameIsIf() { 30 | assertThat(javaGetters.getIf()).isEqualTo(javaGetters.`if`) 31 | } 32 | 33 | @Test 34 | fun getAs_impliedPropertyNameIsAs() { 35 | assertThat(javaGetters.getAs()).isEqualTo(javaGetters.`as`) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /j2kt/jre/javatests/interop/JavaGetters.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package interop; 17 | 18 | /** Check how some "interesting" getters get translated to Kotlin properties. */ 19 | public final class JavaGetters { 20 | 21 | public JavaGetters() {} 22 | 23 | // Reserved word in Kotlin and Java 24 | public String getIf() { 25 | return "if"; 26 | } 27 | 28 | // Reserved word in Kotlin only 29 | public String getAs() { 30 | return "as"; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /j2kt/jre/javatests/interop/README.md: -------------------------------------------------------------------------------- 1 | Tests here document some aspects of Kotlin Java JVM interoperability that 2 | don't seem to be documented very well. -------------------------------------------------------------------------------- /j2kt/jre/javatests/smoke/CharacterTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package smoke; 18 | 19 | import static org.junit.Assert.assertEquals; 20 | 21 | import org.junit.Test; 22 | import org.junit.runner.RunWith; 23 | import org.junit.runners.JUnit4; 24 | 25 | /** Smoke test for Character. */ 26 | @RunWith(JUnit4.class) 27 | public final class CharacterTest { 28 | 29 | @Test 30 | public void testCharacter() { 31 | assertEquals('U', Character.toUpperCase('u')); 32 | assertEquals('l', Character.toLowerCase('L')); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /j2kt/jre/javatests/smoke/FormatterTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package smoke; 17 | 18 | import static org.junit.Assert.assertEquals; 19 | 20 | import java.util.Formatter; 21 | import org.junit.Test; 22 | import org.junit.runner.RunWith; 23 | import org.junit.runners.JUnit4; 24 | 25 | @RunWith(JUnit4.class) 26 | public final class FormatterTest { 27 | 28 | @Test 29 | public void numberFormat0f_noDot() { 30 | assertEquals("11", new Formatter().format("%.0f", 11.0).toString()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /j2kt/jre/javatests/smoke/LoggingTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package smoke; 17 | 18 | import java.util.logging.Level; 19 | import java.util.logging.Logger; 20 | import org.junit.Test; 21 | import org.junit.runner.RunWith; 22 | import org.junit.runners.JUnit4; 23 | 24 | @RunWith(JUnit4.class) 25 | public final class LoggingTest { 26 | 27 | @Test 28 | public void testLogging() { 29 | Logger logger = Logger.getLogger("j2kt tests"); 30 | logger.log(Level.FINE, "Testing"); 31 | logger.log(Level.SEVERE, "Testing {0}!", "foo"); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /j2kt/jre/javatests/smoke/RandomTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package smoke; 17 | 18 | import static org.junit.Assert.assertEquals; 19 | 20 | import java.util.Random; 21 | import org.junit.Test; 22 | import org.junit.runner.RunWith; 23 | import org.junit.runners.JUnit4; 24 | 25 | @RunWith(JUnit4.class) 26 | public class RandomTest { 27 | 28 | @Test 29 | public void testRandom() { 30 | Random random = new Random(123); 31 | int randomInt = random.nextInt(); 32 | random.setSeed(123); 33 | assertEquals(randomInt, random.nextInt()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /j2kt/jre/javatests/smoke/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | @NullMarked 17 | package smoke; 18 | 19 | import org.jspecify.annotations.NullMarked; 20 | -------------------------------------------------------------------------------- /kmpbench/README.md: -------------------------------------------------------------------------------- 1 | The goal of this porject is to compare Kotlin native and J2KT performance to 2 | current xplat platform performance. 3 | 4 | This package contains a fork and a Kotlin port of a subset of the J2cl 5 | benchmarks and benchmarking infrastructure located at 6 | `google3/third_party/java_src/j2cl/benchmarking/java/com/google/j2cl/benchmarking/framework/` 7 | 8 | Design document: 9 | https://docs.google.com/document/d/17XMMiv8Vp21yAJ-nbJQK1jVeN40kUTJoKbesas6TOe4/edit?usp=sharing&resourcekey=0-EYsIWTLrH5jVIjmisN5i5w 10 | 11 | -------------------------------------------------------------------------------- /kmpbench/com/google/apps/xplat/kmpbench/app/ios/KmpBenchApp.swift: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | import SwiftUI 18 | 19 | @main 20 | struct KmpBenchApp: App { 21 | var body: some Scene { 22 | WindowGroup { 23 | ContentView() 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /kmpbench/com/google/apps/xplat/kmpbench/app/ios/PerfgateLogger.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface PerfgateLogger : NSObject 4 | 5 | - (void)logPerformance:(NSString *)name kt:(double)kt j2objc:(double)j2objc; 6 | 7 | @end -------------------------------------------------------------------------------- /kmpbench/com/google/apps/xplat/kmpbench/app/ios/PerfgateLogger.m: -------------------------------------------------------------------------------- 1 | #import "third_party/java_src/xplat/kmpbench/com/google/apps/xplat/kmpbench/app/ios/PerfgateLogger.h" 2 | #import "googlemac/iPhone/Shared/Testing/Performance/Presto/Presto.h" 3 | 4 | @implementation PerfgateLogger { 5 | PSTLogger *_logger; 6 | } 7 | 8 | - (id)init { 9 | self = [super init]; 10 | if (self != nil) { 11 | self->_logger = [[PSTLogger alloc] init]; 12 | } 13 | return self; 14 | } 15 | 16 | - (void)logPerformance:(NSString *)name kt:(double)kt j2objc:(double)j2objc { 17 | _logger.testName = name; 18 | [_logger log:[PSTEntryBuilder builderWithBlock:^(PSTEntryBuilder *builder) { 19 | [builder add:@"kt" doubleValue:kt]; 20 | [builder add:@"j2objc" doubleValue:j2objc]; 21 | }]]; 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /kmpbench/com/google/apps/xplat/kmpbench/combination/CombinedBenchmark.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package com.google.apps.xplat.kmpbench.combination 17 | 18 | data class CombinedBenchmark( 19 | val name: String, 20 | val kotlinBenchmark: (() -> Double), 21 | val javaBenchmark: (() -> Double) 22 | ) 23 | -------------------------------------------------------------------------------- /kmpbench/gencode_snapshot/README.md: -------------------------------------------------------------------------------- 1 | This directory contains a snapshot of the code generated by j2kt for 2 | simple reference. 3 | 4 | The snapshot is triggered manually, so this might not always be up to date 5 | and shouldn't be considered an authorative reference. 6 | -------------------------------------------------------------------------------- /kmpbench/gencode_snapshot/octane/NavierStokesBenchmark.kt: -------------------------------------------------------------------------------- 1 | // Generated from "com/google/j2cl/benchmarks/octane/NavierStokesBenchmark.java" 2 | package com.google.j2cl.benchmarks.octane 3 | 4 | import javaemul.lang.* 5 | import kotlin.jvm.* 6 | 7 | open class NavierStokesBenchmark: com.google.j2cl.benchmarking.framework.AbstractBenchmark() { 8 | @kotlin.jvm.JvmField var navierStokes: com.google.j2cl.benchmarks.octane.navierstokes.NavierStokes? = null 9 | 10 | open override fun run(): kotlin.Any? { 11 | this.navierStokes!!.runNavierStokes() 12 | return null 13 | } 14 | 15 | open override fun setupOneTime() { 16 | this.navierStokes = com.google.j2cl.benchmarks.octane.navierstokes.NavierStokes() 17 | this.navierStokes!!.setup() 18 | } 19 | 20 | open override fun tearDownOneTime() { 21 | this.navierStokes!!.tearDown() 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /kmpbench/gencode_snapshot/octane/RayTraceBenchmark.kt: -------------------------------------------------------------------------------- 1 | // Generated from "com/google/j2cl/benchmarks/octane/RayTraceBenchmark.java" 2 | package com.google.j2cl.benchmarks.octane 3 | 4 | import javaemul.lang.* 5 | import kotlin.jvm.* 6 | 7 | open class RayTraceBenchmark: com.google.j2cl.benchmarking.framework.AbstractBenchmark() { 8 | open override fun run(): kotlin.Any? { 9 | com.google.j2cl.benchmarks.octane.raytrace.RayTrace.renderScene() 10 | return null 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /kmpbench/gencode_snapshot/octane/RichardsBenchmark.kt: -------------------------------------------------------------------------------- 1 | // Generated from "com/google/j2cl/benchmarks/octane/RichardsBenchmark.java" 2 | package com.google.j2cl.benchmarks.octane 3 | 4 | import javaemul.lang.* 5 | import kotlin.jvm.* 6 | 7 | open class RichardsBenchmark: com.google.j2cl.benchmarking.framework.AbstractBenchmark() { 8 | @kotlin.jvm.JvmField var richards: com.google.j2cl.benchmarks.octane.richards.Richards? = null 9 | 10 | open override fun setupOneTime() { 11 | this.richards = com.google.j2cl.benchmarks.octane.richards.Richards() 12 | } 13 | 14 | open override fun run(): kotlin.Any? { 15 | this.richards!!.runRichards() 16 | return null 17 | } 18 | 19 | open override fun tearDownOneTime() { 20 | this.richards = null 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /kmpbench/gencode_snapshot/octane/raytrace/Background.kt: -------------------------------------------------------------------------------- 1 | // Generated from "com/google/j2cl/benchmarks/octane/raytrace/Background.java" 2 | package com.google.j2cl.benchmarks.octane.raytrace 3 | 4 | import javaemul.lang.* 5 | import kotlin.jvm.* 6 | 7 | open class Background { 8 | @kotlin.jvm.JvmField val color: com.google.j2cl.benchmarks.octane.raytrace.Color? 9 | 10 | @kotlin.jvm.JvmField val ambience: kotlin.Double 11 | 12 | constructor(color: com.google.j2cl.benchmarks.octane.raytrace.Color?, ambience: kotlin.Double) { 13 | this.color = color 14 | this.ambience = ambience 15 | } 16 | 17 | open fun getColor(): com.google.j2cl.benchmarks.octane.raytrace.Color? { 18 | return this.color 19 | } 20 | 21 | open fun getAmbience(): kotlin.Double { 22 | return this.ambience 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /kmpbench/gencode_snapshot/octane/raytrace/BaseMaterial.kt: -------------------------------------------------------------------------------- 1 | // Generated from "com/google/j2cl/benchmarks/octane/raytrace/BaseMaterial.java" 2 | package com.google.j2cl.benchmarks.octane.raytrace 3 | 4 | import javaemul.lang.* 5 | import kotlin.jvm.* 6 | 7 | abstract class BaseMaterial { 8 | @kotlin.jvm.JvmField var gloss: kotlin.Double = 2.0 9 | 10 | @kotlin.jvm.JvmField var transparency: kotlin.Double = 0.0 11 | 12 | @kotlin.jvm.JvmField var reflection: kotlin.Double = 0.0 13 | 14 | @kotlin.jvm.JvmField var hasTexture: kotlin.Boolean = false 15 | 16 | abstract fun getColor(u: kotlin.Double, v: kotlin.Double): com.google.j2cl.benchmarks.octane.raytrace.Color? 17 | 18 | open fun wrapUp(t: kotlin.Double): kotlin.Double { 19 | var t_1: kotlin.Double = t 20 | t_1 = t_1 % 2.0 21 | if (t_1 < (- 1).toDouble()) { 22 | t_1 = t_1 + 2.0 23 | } else if (t_1 >= 1.0) { 24 | t_1 = t_1 - 2.0 25 | } 26 | return t_1 27 | } 28 | 29 | open override fun toString(): kotlin.String { 30 | return "Material [gloss=" + this.gloss + ", transparency=" + this.transparency + ", hasTexture=" + this.hasTexture + "]" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /kmpbench/gencode_snapshot/octane/raytrace/Light.kt: -------------------------------------------------------------------------------- 1 | // Generated from "com/google/j2cl/benchmarks/octane/raytrace/Light.java" 2 | package com.google.j2cl.benchmarks.octane.raytrace 3 | 4 | import javaemul.lang.* 5 | import kotlin.jvm.* 6 | 7 | open class Light { 8 | @kotlin.jvm.JvmField val position: com.google.j2cl.benchmarks.octane.raytrace.Vector? 9 | 10 | @kotlin.jvm.JvmField val color: com.google.j2cl.benchmarks.octane.raytrace.Color? 11 | 12 | constructor(pos: com.google.j2cl.benchmarks.octane.raytrace.Vector?, color: com.google.j2cl.benchmarks.octane.raytrace.Color?) { 13 | this.position = pos 14 | this.color = color 15 | } 16 | 17 | open override fun toString(): kotlin.String { 18 | return "Light [" + this.position!!.getX() + "," + this.position!!.getY() + "," + this.position!!.getZ() + "]" 19 | } 20 | 21 | open fun getPosition(): com.google.j2cl.benchmarks.octane.raytrace.Vector? { 22 | return this.position 23 | } 24 | 25 | open fun getColor(): com.google.j2cl.benchmarks.octane.raytrace.Color? { 26 | return this.color 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /kmpbench/gencode_snapshot/octane/raytrace/MaterialSolid.kt: -------------------------------------------------------------------------------- 1 | // Generated from "com/google/j2cl/benchmarks/octane/raytrace/MaterialSolid.java" 2 | package com.google.j2cl.benchmarks.octane.raytrace 3 | 4 | import javaemul.lang.* 5 | import kotlin.jvm.* 6 | 7 | open class MaterialSolid: com.google.j2cl.benchmarks.octane.raytrace.BaseMaterial { 8 | @kotlin.jvm.JvmField val color: com.google.j2cl.benchmarks.octane.raytrace.Color? 9 | 10 | constructor(color: com.google.j2cl.benchmarks.octane.raytrace.Color?, reflection: kotlin.Double, transparency: kotlin.Double, gloss: kotlin.Double) { 11 | this.color = color 12 | this.reflection = reflection 13 | this.transparency = transparency 14 | this.gloss = gloss 15 | this.hasTexture = false 16 | } 17 | 18 | open override fun getColor(u: kotlin.Double, v: kotlin.Double): com.google.j2cl.benchmarks.octane.raytrace.Color? { 19 | return this.color 20 | } 21 | 22 | open override fun toString(): kotlin.String { 23 | return "SolidMaterial [gloss=" + this.gloss + ", transparency=" + this.transparency + ", hasTexture=" + this.hasTexture + "]" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /kmpbench/gencode_snapshot/octane/raytrace/Ray.kt: -------------------------------------------------------------------------------- 1 | // Generated from "com/google/j2cl/benchmarks/octane/raytrace/Ray.java" 2 | package com.google.j2cl.benchmarks.octane.raytrace 3 | 4 | import javaemul.lang.* 5 | import kotlin.jvm.* 6 | 7 | open class Ray { 8 | @kotlin.jvm.JvmField val position: com.google.j2cl.benchmarks.octane.raytrace.Vector? 9 | 10 | @kotlin.jvm.JvmField val direction: com.google.j2cl.benchmarks.octane.raytrace.Vector? 11 | 12 | constructor(pos: com.google.j2cl.benchmarks.octane.raytrace.Vector?, dir: com.google.j2cl.benchmarks.octane.raytrace.Vector?) { 13 | this.position = pos 14 | this.direction = dir 15 | } 16 | 17 | open override fun toString(): kotlin.String { 18 | return "Ray [" + this.position + "," + this.direction + "]" 19 | } 20 | 21 | open fun getPosition(): com.google.j2cl.benchmarks.octane.raytrace.Vector? { 22 | return this.position 23 | } 24 | 25 | open fun getDirection(): com.google.j2cl.benchmarks.octane.raytrace.Vector? { 26 | return this.direction 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /kmpbench/gencode_snapshot/octane/raytrace/Shape.kt: -------------------------------------------------------------------------------- 1 | // Generated from "com/google/j2cl/benchmarks/octane/raytrace/Shape.java" 2 | package com.google.j2cl.benchmarks.octane.raytrace 3 | 4 | import javaemul.lang.* 5 | import kotlin.jvm.* 6 | 7 | abstract class Shape { 8 | abstract fun intersect(ray: com.google.j2cl.benchmarks.octane.raytrace.Ray?): com.google.j2cl.benchmarks.octane.raytrace.IntersectionInfo? 9 | 10 | abstract fun getMaterial(): com.google.j2cl.benchmarks.octane.raytrace.BaseMaterial? 11 | 12 | abstract fun getPosition(): com.google.j2cl.benchmarks.octane.raytrace.Vector? 13 | } 14 | -------------------------------------------------------------------------------- /kmpbench/gencode_snapshot/octane/richards/DeviceTask.kt: -------------------------------------------------------------------------------- 1 | // Generated from "com/google/j2cl/benchmarks/octane/richards/DeviceTask.java" 2 | package com.google.j2cl.benchmarks.octane.richards 3 | 4 | import javaemul.lang.* 5 | import kotlin.jvm.* 6 | 7 | open class DeviceTask: com.google.j2cl.benchmarks.octane.richards.Task { 8 | @kotlin.jvm.JvmField val scheduler: com.google.j2cl.benchmarks.octane.richards.Scheduler? 9 | 10 | @kotlin.jvm.JvmField var v1: com.google.j2cl.benchmarks.octane.richards.Packet? = null 11 | 12 | constructor(scheduler: com.google.j2cl.benchmarks.octane.richards.Scheduler?) { 13 | this.scheduler = scheduler 14 | this.v1 = null 15 | } 16 | 17 | open override fun run(packet: com.google.j2cl.benchmarks.octane.richards.Packet?): com.google.j2cl.benchmarks.octane.richards.TaskControlBlock? { 18 | if (packet === null) { 19 | if (this.v1 === null) { 20 | return this.scheduler!!.suspendCurrent() 21 | } 22 | val v: com.google.j2cl.benchmarks.octane.richards.Packet? = this.v1 23 | this.v1 = null 24 | return this.scheduler!!.queue(v) 25 | } else { 26 | this.v1 = packet 27 | return this.scheduler!!.holdCurrent() 28 | } 29 | } 30 | 31 | open override fun toString(): kotlin.String { 32 | return "DeviceTask" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /kmpbench/gencode_snapshot/octane/richards/Task.kt: -------------------------------------------------------------------------------- 1 | // Generated from "com/google/j2cl/benchmarks/octane/richards/Task.java" 2 | package com.google.j2cl.benchmarks.octane.richards 3 | 4 | import javaemul.lang.* 5 | import kotlin.jvm.* 6 | 7 | fun interface Task { 8 | fun run(packet: com.google.j2cl.benchmarks.octane.richards.Packet?): com.google.j2cl.benchmarks.octane.richards.TaskControlBlock? 9 | } 10 | -------------------------------------------------------------------------------- /kmpbench/java/com/google/j2cl/benchmarking/framework/Clock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package com.google.j2cl.benchmarking.framework; 17 | 18 | interface Clock { 19 | double now(); 20 | 21 | Clock DEFAULT = () -> System.nanoTime() / 1000000d; 22 | } 23 | -------------------------------------------------------------------------------- /kmpbench/java/com/google/j2cl/benchmarks/octane/DeltaBlueBenchmark.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package com.google.j2cl.benchmarks.octane; 17 | 18 | import com.google.j2cl.benchmarking.framework.AbstractBenchmark; 19 | import com.google.j2cl.benchmarks.octane.deltablue.DeltaBlue; 20 | 21 | /** 22 | * This is the Java port of the JavaScript implementation of DeltaBlue benchmark from the V8 octane 23 | * benchmark suite. 24 | */ 25 | public class DeltaBlueBenchmark extends AbstractBenchmark { 26 | 27 | @Override 28 | public Object run() { 29 | DeltaBlue.chainTest(100); 30 | DeltaBlue.projectionTest(100); 31 | return null; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /kmpbench/java/com/google/j2cl/benchmarks/octane/RayTraceBenchmark.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package com.google.j2cl.benchmarks.octane; 17 | 18 | import com.google.j2cl.benchmarking.framework.AbstractBenchmark; 19 | import com.google.j2cl.benchmarks.octane.raytrace.RayTrace; 20 | 21 | /** 22 | * This is the Java port of the JavaScript implementation of RayTrace benchmark from the V8 octane 23 | * benchmark suite. 24 | */ 25 | public class RayTraceBenchmark extends AbstractBenchmark { 26 | 27 | @Override 28 | public Object run() { 29 | RayTrace.renderScene(); 30 | return null; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /kmpbench/java/com/google/j2cl/benchmarks/octane/deltablue/Direction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package com.google.j2cl.benchmarks.octane.deltablue; 17 | 18 | class Direction { 19 | 20 | static final int NONE = 0; 21 | static final int FORWARD = 1; 22 | static final int BACKWARD = -1; 23 | 24 | private Direction() {} 25 | } 26 | -------------------------------------------------------------------------------- /kmpbench/java/com/google/j2cl/benchmarks/octane/deltablue/EditConstraint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package com.google.j2cl.benchmarks.octane.deltablue; 17 | 18 | /** A unary input constraint used to mark a variable that the client wishes to change. */ 19 | class EditConstraint extends UnaryConstraint { 20 | 21 | EditConstraint(Variable v, Strength str) { 22 | super(v, str); 23 | } 24 | 25 | /** Edits indicate that a variable is to be changed by imperative code. */ 26 | @Override 27 | boolean isInput() { 28 | return true; 29 | } 30 | 31 | @Override 32 | void execute() { 33 | // Edit constraints do nothing 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /kmpbench/java/com/google/j2cl/benchmarks/octane/deltablue/StayConstraint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package com.google.j2cl.benchmarks.octane.deltablue; 17 | 18 | /** 19 | * Variables that should, with some level of preference, stay the same. Planners may exploit the 20 | * fact that instances, if satisfied, will not change their output during plan execution. This is 21 | * called "stay optimization". 22 | */ 23 | class StayConstraint extends UnaryConstraint { 24 | 25 | StayConstraint(Variable v, Strength strength) { 26 | super(v, strength); 27 | } 28 | 29 | @Override 30 | void execute() { 31 | // Stay constraints do nothing 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /kmpbench/java/com/google/j2cl/benchmarks/octane/raytrace/Background.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package com.google.j2cl.benchmarks.octane.raytrace; 17 | 18 | class Background { 19 | 20 | private final Color color; 21 | private final double ambience; 22 | 23 | Background(Color color, double ambience) { 24 | this.color = color; 25 | this.ambience = ambience; 26 | } 27 | 28 | Color getColor() { 29 | return color; 30 | } 31 | 32 | double getAmbience() { 33 | return ambience; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /kmpbench/java/com/google/j2cl/benchmarks/octane/raytrace/Shape.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package com.google.j2cl.benchmarks.octane.raytrace; 17 | 18 | abstract class Shape { 19 | abstract IntersectionInfo intersect(Ray ray); 20 | 21 | abstract BaseMaterial getMaterial(); 22 | 23 | abstract Vector getPosition(); 24 | } 25 | -------------------------------------------------------------------------------- /kmpbench/java/com/google/j2cl/benchmarks/octane/richards/Task.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package com.google.j2cl.benchmarks.octane.richards; 17 | 18 | interface Task { 19 | 20 | TaskControlBlock run(Packet packet); 21 | } 22 | -------------------------------------------------------------------------------- /kmpbench/java/jarjar-rules.txt: -------------------------------------------------------------------------------- 1 | rule com.google.j2cl.** com.google.apps.xplat.kmpbench.java.@1 2 | -------------------------------------------------------------------------------- /kmpbench/kotlin/com/google/j2cl/benchmarking/framework/Platform.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package com.google.j2cl.benchmarking.framework 18 | 19 | // This is a Kotlin port of the corresponding J2cl Java class in 20 | // google3/third_party/java_src/j2cl/benchmarking/java/com/google/j2cl/benchmarking/framework/ 21 | 22 | /** Helper class defining platform specific operations. */ 23 | internal object Platform { 24 | 25 | // Unsupported 26 | fun forceGc() {} 27 | } 28 | -------------------------------------------------------------------------------- /kmpbench/update_gencode_snapshot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | TARGET="third_party/java_src/xplat/kmpbench/gencode_snapshot" 4 | 5 | mkdir $TARGET 6 | 7 | blaze build third_party/java_src/xplat/kmpbench/java:benchmarks-j2kt-jvm 8 | 9 | # TODO(b/230841155): Use go/vcstool to make this fig compatible 10 | 11 | g4 edit $TARGET/*/*/*.kt $TARGET/*/*.kt 12 | 13 | cp -r blaze-bin/third_party/java_src/xplat/kmpbench/java/benchmarks-j2kt-jvm.kt/com/google/j2cl/benchmarks/* $TARGET 14 | 15 | g4 add $TARGET/*/*/*.kt $TARGET/*/*.kt 16 | --------------------------------------------------------------------------------