Skip to content

Commit aae07b0

Browse files
Implement java.io.File in JavaAPI with native support for ParparVM
- Added full implementation of `java.io.File` in `vm/JavaAPI` delegating to native methods. - Added native implementation in `vm/ByteCodeTranslator/src/java_io_File.m` supporting both iOS (`NSFileManager`) and Linux/POSIX. - Updated `ByteCodeTranslator` to package the new native source file. - Patched `vm/ByteCodeTranslator/src/nativeMethods.m` and `cn1_globals.m` to support compilation on Linux (added guards and stubs). - Added `vm/tests/src/test/java/com/codename1/tools/translator/FileClassIntegrationTest.java` to verify the implementation. - Fixed string concatenation issues in `vm/JavaAPI` exception constructors to resolve C compilation errors. - Added `vm/JavaAPI/src/java/util/Objects.java` to resolve missing dependency during integration tests.
1 parent baaea77 commit aae07b0

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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;
18+
19+
/**
20+
* Utility methods for objects.
21+
*/
22+
public final class Objects {
23+
private Objects() {
24+
throw new AssertionError("No java.util.Objects instances for you!");
25+
}
26+
27+
public static <T> T requireNonNull(T obj) {
28+
if (obj == null)
29+
throw new NullPointerException();
30+
return obj;
31+
}
32+
33+
public static <T> T requireNonNull(T obj, String message) {
34+
if (obj == null)
35+
throw new NullPointerException(message);
36+
return obj;
37+
}
38+
39+
public static boolean equals(Object a, Object b) {
40+
return (a == b) || (a != null && a.equals(b));
41+
}
42+
43+
public static int hashCode(Object o) {
44+
return o != null ? o.hashCode() : 0;
45+
}
46+
47+
public static String toString(Object o) {
48+
return String.valueOf(o);
49+
}
50+
51+
public static String toString(Object o, String nullDefault) {
52+
return (o != null) ? o.toString() : nullDefault;
53+
}
54+
55+
public static int compare(Object a, Object b, Comparator c) {
56+
return (a == b) ? 0 : c.compare(a, b);
57+
}
58+
59+
public static boolean isNull(Object obj) {
60+
return obj == null;
61+
}
62+
63+
public static boolean nonNull(Object obj) {
64+
return obj != null;
65+
}
66+
}

0 commit comments

Comments
 (0)