diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/SystemNativeGenerator.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/SystemNativeGenerator.java index b24ac2f38..09c397042 100644 --- a/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/SystemNativeGenerator.java +++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/SystemNativeGenerator.java @@ -17,12 +17,10 @@ package org.teavm.classlib.java.lang; import java.io.IOException; import org.teavm.codegen.SourceWriter; -import org.teavm.dependency.DependencyChecker; -import org.teavm.dependency.DependencyNode; -import org.teavm.dependency.DependencyPlugin; -import org.teavm.dependency.MethodDependency; +import org.teavm.dependency.*; import org.teavm.javascript.ni.Generator; import org.teavm.javascript.ni.GeneratorContext; +import org.teavm.model.FieldReference; import org.teavm.model.MethodReference; /** @@ -39,6 +37,11 @@ public class SystemNativeGenerator implements Generator, DependencyPlugin { case "currentTimeMillis": generateCurrentTimeMillis(writer); break; + case "setErr": + writer.appendClass("java.lang.System").append('.') + .appendField(new FieldReference("java.lang.System", "err")) + .ws().append('=').ws().append(context.getParameterName(1)).append(";").softNewLine(); + break; } } @@ -48,6 +51,9 @@ public class SystemNativeGenerator implements Generator, DependencyPlugin { case "doArrayCopy": achieveArrayCopy(method); break; + case "setErr": + achieveSetErr(checker, method); + break; } } @@ -71,4 +77,9 @@ public class SystemNativeGenerator implements Generator, DependencyPlugin { DependencyNode dest = method.getVariable(3); src.getArrayItem().connect(dest.getArrayItem()); } + + private void achieveSetErr(DependencyChecker checker, MethodDependency method) { + FieldDependency fieldDep = checker.linkField(new FieldReference("java.lang.System", "err"), method.getStack()); + method.getVariable(1).connect(fieldDep.getValue()); + } } diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TLinkageError.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TLinkageError.java new file mode 100644 index 000000000..6fac68f97 --- /dev/null +++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TLinkageError.java @@ -0,0 +1,36 @@ +/* + * Copyright 2014 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.classlib.java.lang; + +/** + * + * @author Alexey Andreev + */ +public class TLinkageError extends TError { + private static final long serialVersionUID = 9176544705010852435L; + + public TLinkageError() { + super(); + } + + public TLinkageError(TString message, TThrowable cause) { + super(message, cause); + } + + public TLinkageError(TString message) { + super(message); + } +} diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TSystem.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TSystem.java index 770b0177d..2e6755df4 100644 --- a/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TSystem.java +++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TSystem.java @@ -17,6 +17,7 @@ package org.teavm.classlib.java.lang; import org.teavm.classlib.java.io.TPrintStream; import org.teavm.classlib.java.lang.reflect.TArray; +import org.teavm.dependency.PluggableDependency; import org.teavm.javascript.ni.GeneratedBy; /** @@ -60,4 +61,8 @@ public final class TSystem extends TObject { // TODO: make implementation return null; } + + @GeneratedBy(SystemNativeGenerator.class) + @PluggableDependency(SystemNativeGenerator.class) + public static native void setErr(TPrintStream err); }