= 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 extends Annotation> 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 |
--------------------------------------------------------------------------------