Skip to content

Commit

Permalink
Added many types in the list of avoided classes (#26)
Browse files Browse the repository at this point in the history
* Added more classes from JNet

* Reviewed some classes imported from JNet

* Update configuration.json
  • Loading branch information
masesdevelopers authored Jun 1, 2024
1 parent 69670d1 commit d164a52
Show file tree
Hide file tree
Showing 49 changed files with 1,575 additions and 74 deletions.
19 changes: 18 additions & 1 deletion src/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"com.oracle",
"com.sun",
"java.awt.peer",
"java.lang.constant",
"org.burningwave",
"org.graalvm",
"org.hamcrest",
Expand Down Expand Up @@ -78,15 +79,29 @@
"android.util.Range",
"android.util.TypedValue",
"android.widget.ArrayAdapter",
"java.io.ObjectInputFilter",
"java.lang.Module",
"java.lang.ModuleLayer",
"java.lang.ProcessBuilder$Redirect$Type",
"java.lang.ProcessHandle",
"java.lang.Thread$UncaughtExceptionHandler",
"java.lang.reflect.AnnotatedType",
"java.security.SecureRandomParameters",
"java.sql.ConnectionBuilder",
"java.sql.DriverAction",
"java.sql.ShardingKey",
"java.sql.SQLType",
"java.util.Comparator",
"java.util.EventListener",
"java.util.random.RandomGenerator",
"java.util.stream.DoubleStream$Builder",
"java.util.stream.IntStream$Builder",
"java.util.stream.LongStream$Builder",
"java.util.stream.LongStream$LongMapMultiConsumer",
"java.util.stream.Stream$Builder",
"java.util.ServiceLoader$Provider",
"java.util.zip.ZipConstants",
"javax.sql.PooledConnectionBuilder",
"javax.swing.ToolTipManager",
"javax.swing.text.html.HTMLEditorKit$LinkController",
"javax.swing.plaf.basic.BasicButtonListener",
Expand All @@ -108,7 +123,9 @@
"javax.swing.plaf.basic.BasicSliderUI$TrackListener",
"javax.swing.plaf.basic.BasicScrollPaneUI$VSBChangeListener",
"javax.swing.plaf.metal.MetalComboBoxUI$MetalPropertyChangeListener",
"javax.tools.DiagnosticListener"
"javax.tools.DiagnosticListener",
"javax.xml.xpath.XPathEvaluationResult",
"org.w3c.dom.ls.LSSerializerFilter"
],
"NamespacesInConflict": [
"android.system",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
/*
* Copyright 2024 MASES s.r.l.
*
* 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.
*
* Refer to LICENSE for more information.
*/

package org.mases.netdroid.developed;

import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.LongBuffer;
import java.nio.ShortBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class NetdroidHelper {
public static List<?> listFromPrimitiveArray(Object input) {
if (input == null) throw new IllegalArgumentException("Input parameter is null");

if (input instanceof boolean[]) {
final List<Boolean> l = new ArrayList<Boolean>();
for (final boolean s : (boolean[])input) {
l.add(s);
}
return l;
}
else if (input instanceof byte[]) {
final List<Byte> l = new ArrayList<Byte>();
for (final byte s : (byte[])input) {
l.add(s);
}
return l;
}
else if (input instanceof char[]) {
final List<Character> l = new ArrayList<Character>();
for (final char s : (char[])input) {
l.add(s);
}
return l;
}
else if (input instanceof short[]) {
final List<Short> l = new ArrayList<Short>();
for (final short s : (short[])input) {
l.add(s);
}
return l;
}
else if (input instanceof int[]) {
Integer[] array = Arrays.stream((int[])input).boxed().toArray(Integer[]::new);
return Arrays.asList(array);
}
else if (input instanceof long[]) {
Long[] array = Arrays.stream((long[])input).boxed().toArray(Long[]::new);
return Arrays.asList(array);
}
else if (input instanceof float[]) {
final List<Float> l = new ArrayList<Float>();
for (final float s : (float[])input) {
l.add(s);
}
return l;
}
else if (input instanceof double[]) {
Double[] array = Arrays.stream((double[])input).boxed().toArray(Double[]::new);
return Arrays.asList(array);
}

if(!input.getClass().isArray()) throw new IllegalArgumentException("Input parameter is not an array");

throw new ClassCastException(input.getClass().getName() + " cannot be converted with this function");
}

public static List<?> listFromByteBuffer(ByteBuffer input) {
if (input == null) throw new IllegalArgumentException("Input parameter is null");

input.rewind();
byte[] array = new byte[input.remaining()];
input.get(array, 0, array.length);
final List<Byte> l = new ArrayList<Byte>();
for (final byte s : array) {
l.add(s);
}
return l;
}

public static List<?> listFromCharBuffer(CharBuffer input) {
if (input == null) throw new IllegalArgumentException("Input parameter is null");

input.rewind();
char[] array = new char[input.remaining()];
input.get(array, 0, array.length);
final List<Character> l = new ArrayList<Character>();
for (final char s : array) {
l.add(s);
}
return l;
}

public static List<?> listFromDoubleBuffer(DoubleBuffer input) {
if (input == null) throw new IllegalArgumentException("Input parameter is null");

input.rewind();
double[] array = new double[input.remaining()];
input.get(array, 0, array.length);
Double[] array2 = Arrays.stream(array).boxed().toArray(Double[]::new);
return Arrays.asList(array2);
}

public static List<?> listFromFloatBuffer(FloatBuffer input) {
if (input == null) throw new IllegalArgumentException("Input parameter is null");

input.rewind();
float[] array = new float[input.remaining()];
input.get(array, 0, array.length);
final List<Float> l = new ArrayList<Float>();
for (final float s : array) {
l.add(s);
}
return l;
}

public static List<?> listFromIntBuffer(IntBuffer input) {
if (input == null) throw new IllegalArgumentException("Input parameter is null");

input.rewind();
int[] array = new int[input.remaining()];
input.get(array, 0, array.length);
Integer[] array2 = Arrays.stream(array).boxed().toArray(Integer[]::new);
return Arrays.asList(array2);
}

public static List<?> listFromLongBuffer(LongBuffer input) {
if (input == null) throw new IllegalArgumentException("Input parameter is null");

input.rewind();
long[] array = new long[input.remaining()];
input.get(array, 0, array.length);
Long[] array2 = Arrays.stream(array).boxed().toArray(Long[]::new);
return Arrays.asList(array2);
}

public static List<?> listFromShortBuffer(ShortBuffer input) {
if (input == null) throw new IllegalArgumentException("Input parameter is null");

input.rewind();
short[] array = new short[input.remaining()];
input.get(array, 0, array.length);
final List<Short> l = new ArrayList<Short>();
for (final short s : array) {
l.add(s);
}
return l;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Java.Lang
/// <summary>
/// .NET implementations of <see href="https://docs.oracle.com/javase/8/docs/api/java/lang/ArithmeticException.html"/>
/// </summary>
public class ArithmeticException : JVMBridgeException<ArithmeticException>
public class ArithmeticException : RuntimeException
{
/// <summary>
/// <see href="https://www.jcobridge.com/api-clr/html/P_MASES_JCOBridge_C2JBridge_JVMBridgeException_BridgeClassName.htm"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Java.Lang
/// <summary>
/// .NET implementations of <see href="https://docs.oracle.com/javase/8/docs/api/java/lang/ArrayIndexOutOfBoundsException.html"/>
/// </summary>
public class ArrayIndexOutOfBoundsException : JVMBridgeException<ArrayIndexOutOfBoundsException>
public class ArrayIndexOutOfBoundsException : IndexOutOfBoundsException
{
/// <summary>
/// <see href="https://www.jcobridge.com/api-clr/html/P_MASES_JCOBridge_C2JBridge_JVMBridgeException_BridgeClassName.htm"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Java.Lang
/// <summary>
/// .NET implementations of <see href="https://docs.oracle.com/javase/8/docs/api/java/lang/ArrayStoreException.html"/>
/// </summary>
public class ArrayStoreException : JVMBridgeException<ArrayStoreException>
public class ArrayStoreException : RuntimeException
{
/// <summary>
/// <see href="https://www.jcobridge.com/api-clr/html/P_MASES_JCOBridge_C2JBridge_JVMBridgeException_BridgeClassName.htm"/>
Expand Down
2 changes: 1 addition & 1 deletion src/net/Netdroid/Developed/Java/Lang/Boolean.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

using MASES.JCOBridge.C2JBridge;
using MASES.JNet.Specific.Extensions;
using MASES.Netdroid.Specific.Extensions;
using System;

namespace Java.Lang
Expand Down
2 changes: 1 addition & 1 deletion src/net/Netdroid/Developed/Java/Lang/Byte.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

using MASES.JCOBridge.C2JBridge;
using MASES.JNet.Specific.Extensions;
using MASES.Netdroid.Specific.Extensions;
using System;

namespace Java.Lang
Expand Down
2 changes: 1 addition & 1 deletion src/net/Netdroid/Developed/Java/Lang/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

using MASES.JCOBridge.C2JBridge;
using MASES.JNet.Specific.Extensions;
using MASES.Netdroid.Specific.Extensions;
using System;

namespace Java.Lang
Expand Down
2 changes: 1 addition & 1 deletion src/net/Netdroid/Developed/Java/Lang/ClassCastException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Java.Lang
/// <summary>
/// .NET implementations of <see href="https://docs.oracle.com/javase/8/docs/api/java/lang/ClassCastException.html"/>
/// </summary>
public class ClassCastException : JVMBridgeException<ClassCastException>
public class ClassCastException : RuntimeException
{
/// <summary>
/// <see href="https://www.jcobridge.com/api-clr/html/P_MASES_JCOBridge_C2JBridge_JVMBridgeException_BridgeClassName.htm"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Java.Lang
/// <summary>
/// .NET implementations of <see href="https://docs.oracle.com/javase/8/docs/api/java/lang/ClassNotFoundException.html"/>
/// </summary>
public class ClassNotFoundException : JVMBridgeException<ClassNotFoundException>
public class ClassNotFoundException : ReflectiveOperationException
{
/// <summary>
/// <see href="https://www.jcobridge.com/api-clr/html/P_MASES_JCOBridge_C2JBridge_JVMBridgeException_BridgeClassName.htm"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Java.Lang
/// <summary>
/// .NET implementations of <see href="https://docs.oracle.com/javase/8/docs/api/java/lang/CloneNotSupportedException.html"/>
/// </summary>
public class CloneNotSupportedException : JVMBridgeException<CloneNotSupportedException>
public class CloneNotSupportedException : Java.Lang.Exception
{
/// <summary>
/// <see href="https://www.jcobridge.com/api-clr/html/P_MASES_JCOBridge_C2JBridge_JVMBridgeException_BridgeClassName.htm"/>
Expand Down
37 changes: 0 additions & 37 deletions src/net/Netdroid/Developed/Java/Lang/Compiler.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/net/Netdroid/Developed/Java/Lang/Double.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

using MASES.JCOBridge.C2JBridge;
using MASES.JNet.Specific.Extensions;
using MASES.Netdroid.Specific.Extensions;
using System;

namespace Java.Lang
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Java.Lang
/// <summary>
/// .NET implementations of <see href="https://docs.oracle.com/javase/8/docs/api/java/lang/EnumConstantNotPresentException.html"/>
/// </summary>
public class EnumConstantNotPresentException : JVMBridgeException<EnumConstantNotPresentException>
public class EnumConstantNotPresentException : RuntimeException
{
/// <summary>
/// <see href="https://www.jcobridge.com/api-clr/html/P_MASES_JCOBridge_C2JBridge_JVMBridgeException_BridgeClassName.htm"/>
Expand Down
2 changes: 1 addition & 1 deletion src/net/Netdroid/Developed/Java/Lang/Exception.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Java.Lang
/// <summary>
/// .NET implementations of <see href="https://docs.oracle.com/javase/8/docs/api/java/lang/Exception.html"/>
/// </summary>
public class Exception : JVMBridgeException<Exception>
public class Exception : Throwable
{
/// <summary>
/// <see href="https://www.jcobridge.com/api-clr/html/P_MASES_JCOBridge_C2JBridge_JVMBridgeException_BridgeClassName.htm"/>
Expand Down
2 changes: 1 addition & 1 deletion src/net/Netdroid/Developed/Java/Lang/Float.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

using MASES.JCOBridge.C2JBridge;
using MASES.JNet.Specific.Extensions;
using MASES.Netdroid.Specific.Extensions;
using System;

namespace Java.Lang
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Java.Lang
/// <summary>
/// .NET implementations of <see href="https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalAccessException.html"/>
/// </summary>
public class IllegalAccessException : JVMBridgeException<IllegalAccessException>
public class IllegalAccessException : ReflectiveOperationException
{
/// <summary>
/// <see href="https://www.jcobridge.com/api-clr/html/P_MASES_JCOBridge_C2JBridge_JVMBridgeException_BridgeClassName.htm"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Java.Lang
/// <summary>
/// .NET implementations of <see href="https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalArgumentException.html"/>
/// </summary>
public class IllegalArgumentException : JVMBridgeException<IllegalArgumentException>
public class IllegalArgumentException : RuntimeException
{
/// <summary>
/// <see href="https://www.jcobridge.com/api-clr/html/P_MASES_JCOBridge_C2JBridge_JVMBridgeException_BridgeClassName.htm"/>
Expand Down
Loading

0 comments on commit d164a52

Please sign in to comment.