Skip to content

Commit

Permalink
Merge pull request #43569 from warunalakshitha/refactorRuntime
Browse files Browse the repository at this point in the history
[Java 21] Refactor ballerina runtime
  • Loading branch information
warunalakshitha authored Nov 12, 2024
2 parents 16f7b0c + 556ffe0 commit 7fc1d38
Show file tree
Hide file tree
Showing 298 changed files with 591 additions and 763 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import io.ballerina.projects.util.ProjectUtils;
import io.ballerina.runtime.api.values.BError;
import io.ballerina.runtime.internal.BalRuntime;
import io.ballerina.runtime.internal.ClassloaderRuntime;
import io.ballerina.runtime.internal.scheduling.ClassloaderRuntime;
import io.ballerina.shell.DiagnosticReporter;
import io.ballerina.shell.exceptions.InvokerException;
import io.ballerina.shell.exceptions.InvokerPanicException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package io.ballerina.runtime.profiler.ui;

import io.ballerina.runtime.api.values.BArray;
import io.ballerina.runtime.internal.JsonInternalUtils;
import io.ballerina.runtime.internal.json.JsonInternalUtils;
import io.ballerina.runtime.internal.types.BArrayType;
import io.ballerina.runtime.internal.values.BmpStringValue;

Expand All @@ -30,10 +30,10 @@
import java.util.List;
import java.util.Map;

import static io.ballerina.runtime.api.PredefinedTypes.TYPE_STRING;
import static io.ballerina.runtime.api.types.PredefinedTypes.TYPE_JSON;
import static io.ballerina.runtime.api.types.PredefinedTypes.TYPE_STRING;
import static io.ballerina.runtime.profiler.util.Constants.OUT_STREAM;
import static io.ballerina.runtime.profiler.util.Constants.PERFORMANCE_JSON;
import static io.ballerina.runtime.api.PredefinedTypes.TYPE_JSON;

/**
* This class contains the JSON parser of the Ballerina profiler.
Expand Down Expand Up @@ -108,7 +108,7 @@ private Data populateChildNodes(StackTraceItem stackTraceItem, Data current, Str
}

private List<StackTraceItem> populateStackTraceItems(String jsonInput) {
Object jsonObj = io.ballerina.runtime.internal.JsonParser.parse(jsonInput, TYPE_JSON);
Object jsonObj = io.ballerina.runtime.internal.json.JsonParser.parse(jsonInput, TYPE_JSON);
BArray arr = (BArray) jsonObj;
ArrayList<StackTraceItem> stackTraceItems = new ArrayList<>();
for (int i = 0; i < arr.getLength(); i++) {
Expand Down
6 changes: 3 additions & 3 deletions bvm/ballerina-runtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Ballerina runtime API will contain the following sub packages.
| **Package** | **Description** |
|---------------------------------------|--------------------------------------------------|
| io.ballerina.runtime.api | Basic runtime constructs |
| io.ballerina.runtime.api.async | Handle Ballerina asynchronous related constructs |
| io.ballerina.runtime.api.concurrent | Handle Ballerina asynchronous related constructs |
| io.ballerina.runtime.api.constants | Runtime constants |
| io.ballerina.runtime.api.creators | APIs to create types, values, etc. |
| io.ballerina.runtime.api.flags | Runtime flags |
Expand Down Expand Up @@ -103,9 +103,9 @@ The following table summarizes how Ballerina types are mapped to corresponding J
| io.ballerina.runtime.api.Environment | Developers can use this as the first argument of an interop method, Ballerina will inject an instance of `Environment` class when calling. That instance can be used to communicate with the currently executing Ballerina runtime. With `Environment` instance, you can get interop Ballerina function name, path parameters, strand id, strand metadata, current module, current runtime, etc. |
| io.ballerina.runtime.api.Future | This will contain the future value once we call the Ballerina method from API asynchronously. |
| io.ballerina.runtime.api.Module | Represent Java runtime module. |
| io.ballerina.runtime.api.PredefinedTypes | Contains predefined types. |
| io.ballerina.runtime.api.types.PredefinedTypes | Contains predefined types. |
| io.ballerina.runtime.api.Runtime | An instance of the current runtime can be obtained through an `Environment` instance. This will contain APIs to call Ballerina object methods asynchronously. |
| io.ballerina.runtime.api.TypeTags | Contains runtime type tags. |
| io.ballerina.runtime.api.types.TypeTags | Contains runtime type tags. |

## Create a Ballerina value

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package io.ballerina.runtime.api;

import io.ballerina.runtime.api.repository.Repository;
import io.ballerina.runtime.api.types.Parameter;

import java.util.function.Supplier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ public String getName() {
return name;
}

@Deprecated
public String getVersion() {
return majorVersion;
}

public String getMajorVersion() {
return majorVersion;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package io.ballerina.runtime.api;

import io.ballerina.runtime.api.async.StrandMetadata;
import io.ballerina.runtime.api.concurrent.StrandMetadata;
import io.ballerina.runtime.api.values.BFunctionPointer;
import io.ballerina.runtime.api.values.BObject;
import io.ballerina.runtime.internal.BalRuntime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package io.ballerina.runtime.api.async;
package io.ballerina.runtime.api.concurrent;

import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
package io.ballerina.runtime.api.creators;

import io.ballerina.runtime.api.Module;
import io.ballerina.runtime.api.PredefinedTypes;
import io.ballerina.runtime.api.constants.TypeConstants;
import io.ballerina.runtime.api.types.PredefinedTypes;
import io.ballerina.runtime.api.types.Type;
import io.ballerina.runtime.api.utils.StringUtils;
import io.ballerina.runtime.api.values.BError;
import io.ballerina.runtime.api.values.BMap;
import io.ballerina.runtime.api.values.BString;
import io.ballerina.runtime.internal.TypeChecker;
import io.ballerina.runtime.internal.types.BErrorType;
import io.ballerina.runtime.internal.util.RuntimeUtils;
import io.ballerina.runtime.internal.utils.RuntimeUtils;
import io.ballerina.runtime.internal.values.ErrorValue;
import io.ballerina.runtime.internal.values.MapValueImpl;
import io.ballerina.runtime.internal.values.MappingInitialValueEntry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,13 @@
import io.ballerina.runtime.api.values.BXmlItem;
import io.ballerina.runtime.api.values.BXmlQName;
import io.ballerina.runtime.api.values.BXmlSequence;
import io.ballerina.runtime.internal.DecimalValueKind;
import io.ballerina.runtime.internal.JsonDataSource;
import io.ballerina.runtime.internal.ValueUtils;
import io.ballerina.runtime.internal.XmlFactory;
import io.ballerina.runtime.internal.util.RuntimeUtils;
import io.ballerina.runtime.internal.json.JsonDataSource;
import io.ballerina.runtime.internal.utils.RuntimeUtils;
import io.ballerina.runtime.internal.utils.ValueUtils;
import io.ballerina.runtime.internal.values.ArrayValue;
import io.ballerina.runtime.internal.values.ArrayValueImpl;
import io.ballerina.runtime.internal.values.DecimalValue;
import io.ballerina.runtime.internal.values.DecimalValueKind;
import io.ballerina.runtime.internal.values.FPValue;
import io.ballerina.runtime.internal.values.HandleValue;
import io.ballerina.runtime.internal.values.ListInitialValueEntry;
Expand All @@ -67,6 +66,7 @@
import io.ballerina.runtime.internal.values.XmlItem;
import io.ballerina.runtime.internal.values.XmlQName;
import io.ballerina.runtime.internal.values.XmlSequence;
import io.ballerina.runtime.internal.xml.XmlFactory;

import java.io.InputStream;
import java.math.BigDecimal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.ballerina.runtime.api;
package io.ballerina.runtime.api.repository;

import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.ballerina.runtime.api;
package io.ballerina.runtime.api.repository;

import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.ballerina.runtime.api;
package io.ballerina.runtime.api.repository;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,10 @@
* specific language governing permissions and limitations
* under the License.
*/
package io.ballerina.runtime.api;
package io.ballerina.runtime.api.types;

import io.ballerina.runtime.api.Module;
import io.ballerina.runtime.api.constants.TypeConstants;
import io.ballerina.runtime.api.types.AnyType;
import io.ballerina.runtime.api.types.AnydataType;
import io.ballerina.runtime.api.types.ArrayType;
import io.ballerina.runtime.api.types.BooleanType;
import io.ballerina.runtime.api.types.ByteType;
import io.ballerina.runtime.api.types.DecimalType;
import io.ballerina.runtime.api.types.ErrorType;
import io.ballerina.runtime.api.types.FloatType;
import io.ballerina.runtime.api.types.FutureType;
import io.ballerina.runtime.api.types.HandleType;
import io.ballerina.runtime.api.types.IntegerType;
import io.ballerina.runtime.api.types.IteratorType;
import io.ballerina.runtime.api.types.JsonType;
import io.ballerina.runtime.api.types.MapType;
import io.ballerina.runtime.api.types.NeverType;
import io.ballerina.runtime.api.types.NullType;
import io.ballerina.runtime.api.types.ReadonlyType;
import io.ballerina.runtime.api.types.RecordType;
import io.ballerina.runtime.api.types.ServiceType;
import io.ballerina.runtime.api.types.StreamType;
import io.ballerina.runtime.api.types.StringType;
import io.ballerina.runtime.api.types.Type;
import io.ballerina.runtime.api.types.TypedescType;
import io.ballerina.runtime.api.types.UnionType;
import io.ballerina.runtime.api.types.XmlAttributesType;
import io.ballerina.runtime.api.types.XmlType;
import io.ballerina.runtime.internal.IteratorUtils;
import io.ballerina.runtime.internal.types.BAnyType;
import io.ballerina.runtime.internal.types.BAnydataType;
import io.ballerina.runtime.internal.types.BArrayType;
Expand All @@ -70,6 +44,7 @@
import io.ballerina.runtime.internal.types.BUnionType;
import io.ballerina.runtime.internal.types.BXmlAttributesType;
import io.ballerina.runtime.internal.types.BXmlType;
import io.ballerina.runtime.internal.utils.IteratorUtils;
import io.ballerina.runtime.internal.values.ReadOnlyUtils;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package io.ballerina.runtime.api;
package io.ballerina.runtime.api.types;

/**
* This class contains tag values of each type in Ballerina.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,30 @@
*/
package io.ballerina.runtime.api.utils;

import io.ballerina.runtime.api.PredefinedTypes;
import io.ballerina.runtime.api.TypeTags;
import io.ballerina.runtime.api.creators.ErrorCreator;
import io.ballerina.runtime.api.creators.TypeCreator;
import io.ballerina.runtime.api.creators.ValueCreator;
import io.ballerina.runtime.api.types.JsonType;
import io.ballerina.runtime.api.types.MapType;
import io.ballerina.runtime.api.types.PredefinedTypes;
import io.ballerina.runtime.api.types.StructureType;
import io.ballerina.runtime.api.types.TableType;
import io.ballerina.runtime.api.types.Type;
import io.ballerina.runtime.api.types.TypeTags;
import io.ballerina.runtime.api.values.BArray;
import io.ballerina.runtime.api.values.BError;
import io.ballerina.runtime.api.values.BIterator;
import io.ballerina.runtime.api.values.BMap;
import io.ballerina.runtime.api.values.BRefValue;
import io.ballerina.runtime.api.values.BString;
import io.ballerina.runtime.api.values.BTable;
import io.ballerina.runtime.internal.JsonGenerator;
import io.ballerina.runtime.internal.JsonInternalUtils;
import io.ballerina.runtime.internal.JsonParser;
import io.ballerina.runtime.internal.TypeChecker;
import io.ballerina.runtime.internal.commons.TypeValuePair;
import io.ballerina.runtime.internal.errors.ErrorCodes;
import io.ballerina.runtime.internal.errors.ErrorHelper;
import io.ballerina.runtime.internal.json.JsonGenerator;
import io.ballerina.runtime.internal.json.JsonInternalUtils;
import io.ballerina.runtime.internal.json.JsonParser;

import java.io.IOException;
import java.io.InputStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@
*/
package io.ballerina.runtime.api.utils;

import io.ballerina.runtime.api.TypeTags;
import io.ballerina.runtime.api.creators.ErrorCreator;
import io.ballerina.runtime.api.types.Type;
import io.ballerina.runtime.api.types.TypeTags;
import io.ballerina.runtime.api.values.BArray;
import io.ballerina.runtime.api.values.BError;
import io.ballerina.runtime.api.values.BLink;
import io.ballerina.runtime.api.values.BString;
import io.ballerina.runtime.internal.JsonGenerator;
import io.ballerina.runtime.internal.TypeChecker;
import io.ballerina.runtime.internal.errors.ErrorCodes;
import io.ballerina.runtime.internal.errors.ErrorHelper;
import io.ballerina.runtime.internal.json.JsonGenerator;
import io.ballerina.runtime.internal.values.ArrayValue;
import io.ballerina.runtime.internal.values.ArrayValueImpl;
import io.ballerina.runtime.internal.values.BmpStringValue;
Expand All @@ -48,9 +48,9 @@
import static io.ballerina.runtime.internal.errors.ErrorReasons.INDEX_OUT_OF_RANGE_ERROR_IDENTIFIER;
import static io.ballerina.runtime.internal.errors.ErrorReasons.STRING_OPERATION_ERROR;
import static io.ballerina.runtime.internal.errors.ErrorReasons.getModulePrefixedReason;
import static io.ballerina.runtime.internal.util.StringUtils.getExpressionStringVal;
import static io.ballerina.runtime.internal.util.StringUtils.getStringVal;
import static io.ballerina.runtime.internal.util.StringUtils.parseExpressionStringVal;
import static io.ballerina.runtime.internal.utils.StringUtils.getExpressionStringVal;
import static io.ballerina.runtime.internal.utils.StringUtils.getStringVal;
import static io.ballerina.runtime.internal.utils.StringUtils.parseExpressionStringVal;

/**
* Common utility methods used for String manipulation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,33 @@
*/
package io.ballerina.runtime.api.utils;

import io.ballerina.runtime.api.TypeTags;
import io.ballerina.runtime.api.constants.TypeConstants;
import io.ballerina.runtime.api.types.IntersectionType;
import io.ballerina.runtime.api.types.ReferenceType;
import io.ballerina.runtime.api.types.Type;
import io.ballerina.runtime.api.types.TypeTags;
import io.ballerina.runtime.internal.TypeChecker;
import io.ballerina.runtime.internal.types.BArrayType;
import io.ballerina.runtime.internal.types.BFiniteType;

import static io.ballerina.runtime.api.PredefinedTypes.TYPE_ANY;
import static io.ballerina.runtime.api.PredefinedTypes.TYPE_ANYDATA;
import static io.ballerina.runtime.api.PredefinedTypes.TYPE_BOOLEAN;
import static io.ballerina.runtime.api.PredefinedTypes.TYPE_BYTE;
import static io.ballerina.runtime.api.PredefinedTypes.TYPE_DECIMAL;
import static io.ballerina.runtime.api.PredefinedTypes.TYPE_ERROR;
import static io.ballerina.runtime.api.PredefinedTypes.TYPE_FLOAT;
import static io.ballerina.runtime.api.PredefinedTypes.TYPE_FUTURE;
import static io.ballerina.runtime.api.PredefinedTypes.TYPE_INT;
import static io.ballerina.runtime.api.PredefinedTypes.TYPE_JSON;
import static io.ballerina.runtime.api.PredefinedTypes.TYPE_MAP;
import static io.ballerina.runtime.api.PredefinedTypes.TYPE_NEVER;
import static io.ballerina.runtime.api.PredefinedTypes.TYPE_NULL;
import static io.ballerina.runtime.api.PredefinedTypes.TYPE_STREAM;
import static io.ballerina.runtime.api.PredefinedTypes.TYPE_STRING;
import static io.ballerina.runtime.api.PredefinedTypes.TYPE_TYPEDESC;
import static io.ballerina.runtime.api.PredefinedTypes.TYPE_XML;
import static io.ballerina.runtime.api.PredefinedTypes.TYPE_XML_ATTRIBUTES;
import static io.ballerina.runtime.api.types.PredefinedTypes.TYPE_ANY;
import static io.ballerina.runtime.api.types.PredefinedTypes.TYPE_ANYDATA;
import static io.ballerina.runtime.api.types.PredefinedTypes.TYPE_BOOLEAN;
import static io.ballerina.runtime.api.types.PredefinedTypes.TYPE_BYTE;
import static io.ballerina.runtime.api.types.PredefinedTypes.TYPE_DECIMAL;
import static io.ballerina.runtime.api.types.PredefinedTypes.TYPE_ERROR;
import static io.ballerina.runtime.api.types.PredefinedTypes.TYPE_FLOAT;
import static io.ballerina.runtime.api.types.PredefinedTypes.TYPE_FUTURE;
import static io.ballerina.runtime.api.types.PredefinedTypes.TYPE_INT;
import static io.ballerina.runtime.api.types.PredefinedTypes.TYPE_JSON;
import static io.ballerina.runtime.api.types.PredefinedTypes.TYPE_MAP;
import static io.ballerina.runtime.api.types.PredefinedTypes.TYPE_NEVER;
import static io.ballerina.runtime.api.types.PredefinedTypes.TYPE_NULL;
import static io.ballerina.runtime.api.types.PredefinedTypes.TYPE_STREAM;
import static io.ballerina.runtime.api.types.PredefinedTypes.TYPE_STRING;
import static io.ballerina.runtime.api.types.PredefinedTypes.TYPE_TYPEDESC;
import static io.ballerina.runtime.api.types.PredefinedTypes.TYPE_XML;
import static io.ballerina.runtime.api.types.PredefinedTypes.TYPE_XML_ATTRIBUTES;

/**
* This class contains various methods to manipulate {@link Type}s in Ballerina.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import io.ballerina.runtime.api.types.AnydataType;
import io.ballerina.runtime.api.types.Type;
import io.ballerina.runtime.api.values.BError;
import io.ballerina.runtime.internal.JsonParser;
import io.ballerina.runtime.internal.ValueConverter;
import io.ballerina.runtime.internal.json.JsonParser;
import io.ballerina.runtime.internal.utils.ValueConverter;

import java.io.InputStream;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import io.ballerina.runtime.api.values.BTable;
import io.ballerina.runtime.api.values.BXml;
import io.ballerina.runtime.api.values.BXmlQName;
import io.ballerina.runtime.internal.XmlFactory;
import io.ballerina.runtime.internal.XmlValidator;
import io.ballerina.runtime.internal.values.TableValueImpl;
import io.ballerina.runtime.internal.xml.XmlFactory;
import io.ballerina.runtime.internal.xml.XmlValidator;

import java.io.InputStream;
import java.io.Reader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
package io.ballerina.runtime.api.values;

import io.ballerina.runtime.api.types.Type;
import io.ballerina.runtime.internal.DecimalValueKind;
import io.ballerina.runtime.internal.values.DecimalValue;
import io.ballerina.runtime.internal.values.DecimalValueKind;

import java.math.BigDecimal;

Expand Down
Loading

0 comments on commit 7fc1d38

Please sign in to comment.