@@ -149,7 +149,40 @@ private void writeMockJavaClasses(Path sourceDir) throws Exception {
149149 " private int offset;\n " +
150150 " private int count;\n " +
151151 " public String(char[] v) { value = v; count=v.length; }\n " +
152+ " public String(char[] v, int off, int len) { value = v; offset = off; count = len; }\n " +
152153 " public static String valueOf(Object obj) { return obj == null ? \" null\" : obj.toString(); }\n " +
154+ " public byte[] getBytes() { return new byte[0]; }\n " +
155+ " public byte[] getBytes(String charset) { return new byte[0]; }\n " +
156+ " public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) {\n " +
157+ " for (int i = srcBegin; i < srcEnd; i++) { dst[dstBegin + i - srcBegin] = value[offset + i]; }\n " +
158+ " }\n " +
159+ " public int length() { return count; }\n " +
160+ "}\n " ).getBytes (StandardCharsets .UTF_8 ));
161+
162+ // Primitive wrappers
163+ Files .write (lang .resolve ("Boolean.java" ), ("package java.lang;\n " +
164+ "public final class Boolean {\n " +
165+ " private final boolean value;\n " +
166+ " public Boolean(boolean value) { this.value = value; }\n " +
167+ " public boolean booleanValue() { return value; }\n " +
168+ "}\n " ).getBytes (StandardCharsets .UTF_8 ));
169+ Files .write (lang .resolve ("Byte.java" ), ("package java.lang;\n " +
170+ "public final class Byte {\n " +
171+ " private final byte value;\n " +
172+ " public Byte(byte value) { this.value = value; }\n " +
173+ " public byte byteValue() { return value; }\n " +
174+ "}\n " ).getBytes (StandardCharsets .UTF_8 ));
175+ Files .write (lang .resolve ("Short.java" ), ("package java.lang;\n " +
176+ "public final class Short {\n " +
177+ " private final short value;\n " +
178+ " public Short(short value) { this.value = value; }\n " +
179+ " public short shortValue() { return value; }\n " +
180+ "}\n " ).getBytes (StandardCharsets .UTF_8 ));
181+ Files .write (lang .resolve ("Character.java" ), ("package java.lang;\n " +
182+ "public final class Character {\n " +
183+ " private final char value;\n " +
184+ " public Character(char value) { this.value = value; }\n " +
185+ " public char charValue() { return value; }\n " +
153186 "}\n " ).getBytes (StandardCharsets .UTF_8 ));
154187
155188 // java.lang.StringBuilder
@@ -216,6 +249,29 @@ private void writeMockJavaClasses(Path sourceDir) throws Exception {
216249 " public String toString() { return \" \" +value; }\n " +
217250 "}\n " ).getBytes (StandardCharsets .UTF_8 ));
218251
252+ // Additional primitive wrappers
253+ Files .write (lang .resolve ("Long.java" ), ("package java.lang;\n " +
254+ "public final class Long extends Number {\n " +
255+ " private final long value;\n " +
256+ " public Long(long value) { this.value = value; }\n " +
257+ " public long longValue() { return value; }\n " +
258+ " public int intValue() { return (int)value; }\n " +
259+ "}\n " ).getBytes (StandardCharsets .UTF_8 ));
260+ Files .write (lang .resolve ("Float.java" ), ("package java.lang;\n " +
261+ "public final class Float extends Number {\n " +
262+ " private final float value;\n " +
263+ " public Float(float value) { this.value = value; }\n " +
264+ " public float floatValue() { return value; }\n " +
265+ " public int intValue() { return (int)value; }\n " +
266+ "}\n " ).getBytes (StandardCharsets .UTF_8 ));
267+ Files .write (lang .resolve ("Double.java" ), ("package java.lang;\n " +
268+ "public final class Double extends Number {\n " +
269+ " private final double value;\n " +
270+ " public Double(double value) { this.value = value; }\n " +
271+ " public double doubleValue() { return value; }\n " +
272+ " public int intValue() { return (int)value; }\n " +
273+ "}\n " ).getBytes (StandardCharsets .UTF_8 ));
274+
219275 // java.lang.Number
220276 Files .write (lang .resolve ("Number.java" ), ("package java.lang;\n " +
221277 "public abstract class Number implements java.io.Serializable {\n " +
0 commit comments