Adds JCL classes and methods

This commit is contained in:
konsoletyper 2014-02-20 21:24:35 +04:00
parent f63d0cd8d0
commit dfafbceede
26 changed files with 805 additions and 21 deletions

View File

@ -66,10 +66,13 @@ public class ClassNativeGenerator implements Generator, Injector, DependencyPlug
generateIsAssignableFrom(context);
break;
case "booleanClass":
generateBooleanClass(context);
context.getWriter().append("$rt_cls($rt_booleancls())");
break;
case "intClass":
generateIntClass(context);
context.getWriter().append("$rt_cls($rt_intcls())");
break;
case "voidClass":
context.getWriter().append("$rt_cls($rt_voidcls())");
break;
case "wrap":
context.writeExpr(context.getArgument(0));
@ -99,14 +102,6 @@ public class ClassNativeGenerator implements Generator, Injector, DependencyPlug
writer.append(".$data)");
}
private void generateBooleanClass(InjectorContext context) throws IOException {
context.getWriter().append("$rt_cls($rt_booleancls())");
}
private void generateIntClass(InjectorContext context) throws IOException {
context.getWriter().append("$rt_cls($rt_intcls())");
}
@Override
public void methodAchieved(DependencyChecker checker, MethodDependency graph) {
switch (graph.getReference().getName()) {

View File

@ -57,6 +57,9 @@ class TAbstractStringBuilder extends TObject implements TSerializable, TCharSequ
}
protected TAbstractStringBuilder append(TString string) {
if (string == null) {
string = TString.wrap("null");
}
ensureCapacity(length + string.length());
int j = length;
for (int i = 0; i < string.length(); ++i) {

View File

@ -42,7 +42,7 @@ public class TClass<T extends TObject> extends TObject {
public native boolean isAssignableFrom(TClass<?> obj);
public TString getName() {
return name;
return new TString(name);
}
public boolean isPrimitive() {
@ -77,6 +77,10 @@ public class TClass<T extends TObject> extends TObject {
@PluggableDependency(ClassNativeGenerator.class)
static native TClass<TInteger> intClass();
@InjectedBy(ClassNativeGenerator.class)
@PluggableDependency(ClassNativeGenerator.class)
static native TClass<TVoid> voidClass();
@InjectedBy(ClassNativeGenerator.class)
@PluggableDependency(ClassNativeGenerator.class)
public static native <S extends TObject> TClass<S> wrap(Class<S> cls);
@ -95,4 +99,14 @@ public class TClass<T extends TObject> extends TObject {
@InjectedBy(ClassNativeGenerator.class)
public native T[] getEnumConstantsImpl();
@SuppressWarnings("unchecked")
public T cast(TObject obj) {
if (obj != null && !isAssignableFrom(TClass.wrap(obj.getClass()))) {
throw new TClassCastException(TString.wrap(new TStringBuilder()
.append(TClass.wrap(obj.getClass()).getName())
.append(TString.wrap(" is not subtype of ")).append(name).toString()));
}
return (T)obj;
}
}

View File

@ -21,6 +21,6 @@ import org.teavm.classlib.java.util.TIterator;
*
* @author Alexey Andreev <konsoletyper@gmail.com>
*/
public interface TIterable<T extends TObject> {
public interface TIterable<T> {
TIterator<T> iterator();
}

View File

@ -0,0 +1,32 @@
/*
* 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 <konsoletyper@gmail.com>
*/
public class TNegativeArraySizeException extends TRuntimeException {
private static final long serialVersionUID = 4838944281468611671L;
public TNegativeArraySizeException() {
super();
}
public TNegativeArraySizeException(TString message) {
super(message);
}
}

View File

@ -0,0 +1,24 @@
/*
* 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 <konsoletyper@gmail.com>
*/
public final class TVoid extends TObject {
public static final TClass<TVoid> TYPE = TClass.voidClass();
}

View File

@ -32,10 +32,18 @@ import org.teavm.model.ValueType;
* @author Alexey Andreev
*/
public class ArrayNativeGenerator implements Generator, DependencyPlugin {
private static final String[] primitives = { "Byte", "Short", "Char", "Int", "Long", "Float", "Double",
"Boolean" };
@Override
public void methodAchieved(DependencyChecker checker, MethodDependency method) {
if (method.getReference().getName().equals("getLength")) {
switch (method.getReference().getName()) {
case "getLength":
achieveGetLength(checker, method);
break;
case "newInstanceImpl":
method.getResult().propagate("[java.lang.Object");
break;
}
}
@ -45,6 +53,9 @@ public class ArrayNativeGenerator implements Generator, DependencyPlugin {
case "getLength":
generateGetLength(context, writer);
break;
case "newInstanceImpl":
generateNewInstance(context, writer);
break;
}
}
@ -70,4 +81,19 @@ public class ArrayNativeGenerator implements Generator, DependencyPlugin {
}
});
}
private void generateNewInstance(GeneratorContext context, SourceWriter writer) throws IOException {
String type = context.getParameterName(1);
String length = context.getParameterName(2);
writer.append("var cls = " + type + ".$data;").softNewLine();
writer.append("if (cls.primitive) {").softNewLine().indent();
for (String primitive : primitives) {
writer.append("if (cls == $rt_" + primitive.toLowerCase() + "cls()) {").indent().softNewLine();
writer.append("return $rt_create" + primitive + "Array(" + length + ");").softNewLine();
writer.outdent().append("}").softNewLine();
}
writer.outdent().append("} else {").indent().softNewLine();
writer.append("return $rt_createArray(cls, " + length + ")").softNewLine();
writer.outdent().append("}").softNewLine();
}
}

View File

@ -15,8 +15,7 @@
*/
package org.teavm.classlib.java.lang.reflect;
import org.teavm.classlib.java.lang.TIllegalArgumentException;
import org.teavm.classlib.java.lang.TObject;
import org.teavm.classlib.java.lang.*;
import org.teavm.dependency.PluggableDependency;
import org.teavm.javascript.ni.GeneratedBy;
@ -28,4 +27,21 @@ public final class TArray extends TObject {
@GeneratedBy(ArrayNativeGenerator.class)
@PluggableDependency(ArrayNativeGenerator.class)
public static native int getLength(TObject array) throws TIllegalArgumentException;
public static TObject newInstance(TClass<?> componentType, int length) throws TNegativeArraySizeException {
if (componentType == null) {
throw new TNullPointerException();
}
if (componentType == TClass.wrap(void.class)) {
throw new TIllegalArgumentException();
}
if (length < 0) {
throw new TNegativeArraySizeException();
}
return newInstanceImpl(componentType, length);
}
@GeneratedBy(ArrayNativeGenerator.class)
@PluggableDependency(ArrayNativeGenerator.class)
private static native TObject newInstanceImpl(TClass<?> componentType, int length);
}

View File

@ -0,0 +1,146 @@
/*
* 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.util;
import org.teavm.classlib.java.lang.TObject;
import org.teavm.classlib.java.lang.TUnsupportedOperationException;
/**
*
* @author Alexey Andreev <konsoletyper@gmail.com>
*/
public abstract class TAbstractCollection<E> extends TObject implements TCollection<E> {
protected TAbstractCollection() {
}
@Override
public boolean isEmpty() {
return size() == 0;
}
@Override
public boolean contains(Object o) {
for (TIterator<E> iter = iterator(); iter.hasNext();) {
E e = iter.next();
if (e == null ? o == null : e.equals(o)) {
return true;
}
}
return false;
}
@Override
public Object[] toArray() {
Object[] arr = new Object[size()];
int i = 0;
for (TIterator<E> iter = iterator(); iter.hasNext();) {
arr[i++] = iter.next();
}
return arr;
}
@Override
public <T> T[] toArray(T[] a) {
return null;
}
@Override
public boolean add(E e) {
throw new TUnsupportedOperationException();
}
@Override
public boolean remove(Object o) {
for (TIterator<E> iter = iterator(); iter.hasNext();) {
E e = iter.next();
if (e == null ? o == null : e.equals(o)) {
iter.remove();
return true;
}
}
return false;
}
@Override
public boolean containsAll(TCollection<?> c) {
for (TIterator<?> iter = c.iterator(); iter.hasNext();) {
if (!contains(iter.next())) {
return false;
}
}
return true;
}
@Override
public boolean addAll(TCollection<? extends E> c) {
boolean changed = false;
for (TIterator<? extends E> iter = c.iterator(); iter.hasNext();) {
if (add(iter.next())) {
changed = true;
}
}
return changed;
}
@Override
public boolean removeAll(TCollection<?> c) {
boolean changed = false;
for (TIterator<E> iter = iterator(); iter.hasNext();) {
E e = iter.next();
if (c.contains(e)) {
iter.remove();
changed = true;
}
}
return changed;
}
@Override
public boolean retainAll(TCollection<?> c) {
boolean changed = false;
for (TIterator<E> iter = iterator(); iter.hasNext();) {
E e = iter.next();
if (!c.contains(e)) {
iter.remove();
changed = true;
}
}
return changed;
}
@Override
public void clear() {
for (TIterator<E> iter = iterator(); iter.hasNext();) {
iter.next();
iter.remove();
}
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("[");
TIterator<E> iter = iterator();
if (iter.hasNext()) {
sb.append(String.valueOf(iter.next()));
}
while (iter.hasNext()) {
sb.append(", ").append(String.valueOf(iter.next()));
}
sb.append("]");
return sb.toString();
}
}

View File

@ -0,0 +1,24 @@
/*
* 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.util;
/**
*
* @author Alexey Andreev <konsoletyper@gmail.com>
*/
public class TAbstractList {
}

View File

@ -0,0 +1,48 @@
/*
* 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.util;
import org.teavm.classlib.java.lang.TIterable;
/**
*
* @author Alexey Andreev <konsoletyper@gmail.com>
*/
public interface TCollection<E> extends TIterable<E> {
int size();
boolean isEmpty();
boolean contains(Object o);
Object[] toArray();
<T> T[] toArray(T[] a);
boolean add(E e);
boolean remove(Object o);
boolean containsAll(TCollection<?> c);
boolean addAll(TCollection<? extends E> c);
boolean removeAll(TCollection<?> c);
boolean retainAll(TCollection<?> c);
void clear();
}

View File

@ -0,0 +1,28 @@
/*
* 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.util;
import org.teavm.classlib.java.lang.TObject;
/**
*
* @author Alexey Andreev <konsoletyper@gmail.com>
*/
public interface TComparator<T extends TObject> {
int compare(T o1, T o2);
boolean equals(TObject obj);
}

View File

@ -0,0 +1,44 @@
/*
* 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.util;
import org.teavm.classlib.java.lang.TRuntimeException;
import org.teavm.classlib.java.lang.TString;
import org.teavm.classlib.java.lang.TThrowable;
/**
*
* @author Alexey Andreev <konsoletyper@gmail.com>
*/
public class TConcurrentModificationException extends TRuntimeException {
private static final long serialVersionUID = -2871226388713811335L;
public TConcurrentModificationException() {
super();
}
public TConcurrentModificationException(TString message, TThrowable cause) {
super(message, cause);
}
public TConcurrentModificationException(TString message) {
super(message);
}
public TConcurrentModificationException(TThrowable cause) {
super(cause);
}
}

View File

@ -0,0 +1,56 @@
/*
* 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.util;
/**
*
* @author Alexey Andreev <konsoletyper@gmail.com>
*/
public interface TDeque<E> extends TQueue<E> {
void addFirst(E e);
void addLast(E e);
boolean offerFirst(E e);
boolean offerLast(E e);
E removeFirst();
E removeLast();
E pollFirst();
E pollLast();
E getFirst();
E getLast();
E peekFirst();
E peekLast();
boolean removeFirstOccurrence(Object o);
boolean removeLastOccurrence(Object o);
void push(E e);
E pop();
TIterator<E> descendingIterator();
}

View File

@ -0,0 +1,28 @@
/*
* 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.util;
import org.teavm.classlib.java.lang.TObject;
/**
*
* @author Alexey Andreev <konsoletyper@gmail.com>
*/
public interface TEnumeration<E extends TObject> {
boolean hasMoreElements();
E nextElement();
}

View File

@ -15,13 +15,11 @@
*/
package org.teavm.classlib.java.util;
import org.teavm.classlib.java.lang.TObject;
/**
*
* @author Alexey Andreev <konsoletyper@gmail.com>
*/
public interface TIterator<E extends TObject> {
public interface TIterator<E> {
boolean hasNext();
E next();

View File

@ -0,0 +1,44 @@
/*
* 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.util;
import org.teavm.classlib.java.lang.TObject;
/**
*
* @author Alexey Andreev <konsoletyper@gmail.com>
*/
public interface TList<E extends TObject> extends TCollection<E> {
boolean addAll(int index, TCollection<? extends E> c);
E get(int index);
E set(int index, E element);
void add(int index, E element);
E remove(int index);
int indexOf(Object o);
int lastIndexOf(Object o);
TListIterator<E> listIterator();
TListIterator<E> listIterator(int index);
TList<E> subList(int fromIndex, int toIndex);
}

View File

@ -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.util;
import org.teavm.classlib.java.lang.TObject;
/**
*
* @author Alexey Andreev <konsoletyper@gmail.com>
*/
public interface TListIterator<E extends TObject> extends TIterator<E> {
boolean hasPrevious();
E previous();
int nextIndex();
int previousIndex();
void set(E e);
void add(E e);
}

View File

@ -0,0 +1,56 @@
/*
* 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.util;
import org.teavm.classlib.java.lang.TObject;
/**
*
* @author Alexey Andreev <konsoletyper@gmail.com>
*/
public interface TMap<K, V> {
public static interface Entry<K1, V1> {
K1 getKey();
V1 getValue();
V1 setValue(V1 value);
}
int size();
boolean isEmpty();
boolean containsKey(TObject key);
boolean containsValue(TObject value);
V get(TObject key);
V put(K key, V value);
V remove(TObject key);
void putAll(TMap<? extends K,? extends V> m);
void clear();
TSet<K> keySet();
TCollection<V> values();
TSet<Entry<K, V>> entrySet();
}

View File

@ -0,0 +1,32 @@
/*
* 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.util;
/**
*
* @author Alexey Andreev <konsoletyper@gmail.com>
*/
public interface TQueue<E> extends TCollection<E> {
boolean offer(E e);
E remove();
E poll();
E element();
E peek();
}

View File

@ -0,0 +1,23 @@
/*
* 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.util;
/**
*
* @author Alexey Andreev <konsoletyper@gmail.com>
*/
public interface TRandomAccess {
}

View File

@ -0,0 +1,23 @@
/*
* 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.util;
/**
*
* @author Alexey Andreev <konsoletyper@gmail.com>
*/
public interface TSet<E> extends TCollection<E> {
}

View File

@ -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.util;
import org.teavm.classlib.java.lang.TObject;
/**
*
* @author Alexey Andreev <konsoletyper@gmail.com>
*/
public interface TSortedSet<E extends TObject> extends TSet<E> {
TComparator<? super E> comparator();
TSortedSet<E> subSet(E fromElement, E toElement);
TSortedSet<E> headSet(E toElement);
TSortedSet<E> tailSet(E fromElement);
E first();
E last();
}

View File

@ -77,4 +77,16 @@ public class ClassTest {
public void nonArrayComponentTypeIsNull() {
assertNull(Object.class.getComponentType());
}
@Test
public void castingAppropriateObject() {
Object obj = 23;
assertEquals(Integer.valueOf(23), Integer.class.cast(obj));
}
@Test(expected = ClassCastException.class)
public void inappropriateObjectCastingFails() {
Object obj = 23;
Float.class.cast(obj);
}
}

View File

@ -0,0 +1,40 @@
/*
* 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.reflect;
import static org.junit.Assert.*;
import java.lang.reflect.Array;
import org.junit.Test;
/**
*
* @author Alexey Andreev <konsoletyper@gmail.com>
*/
public class ArrayTest {
@Test
public void createsNewInstance() {
Object instance = Array.newInstance(Object.class, 10);
assertEquals(Object[].class, instance.getClass());
assertEquals(10, Array.getLength(instance));
}
@Test
public void createsNewPrimitiveInstance() {
Object instance = Array.newInstance(int.class, 15);
assertEquals(int[].class, instance.getClass());
assertEquals(15, Array.getLength(instance));
}
}

View File

@ -84,9 +84,9 @@
<scanDependencies>true</scanDependencies>
<outputDir>${project.build.directory}/javascript-tck</outputDir>
<adapterClass>org.teavm.html4j.testing.KOTestAdapter</adapterClass>
<wildcards>
<!-- <wildcards>
<param>net.java.html.js.tests.*Test</param>
</wildcards>
</wildcards> -->
</configuration>
</execution>
</executions>