Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ jobs:
DOTNET_CreateDumpDiagnostics: 1
DOTNET_CreateDumpVerboseDiagnostics: 1
DOTNET_EnableCrashReport: 1
JCOBRIDGE_LicensePath: ${{ secrets.JCOBRIDGE_ENCODED_2_5_21 }}
JCOBRIDGE_LicensePath: ${{ secrets.JCOBRIDGE_ENCODED_2_6_0 }}

steps:
- name: Restore JNet bin from cache
Expand Down Expand Up @@ -428,7 +428,7 @@ jobs:
DOTNET_CreateDumpDiagnostics: 1
DOTNET_CreateDumpVerboseDiagnostics: 1
DOTNET_EnableCrashReport: 1
JCOBRIDGE_LicensePath: ${{ secrets.JCOBRIDGE_ENCODED_2_5_21 }}
JCOBRIDGE_LicensePath: ${{ secrets.JCOBRIDGE_ENCODED_2_6_0 }}

steps:
- uses: actions/setup-dotnet@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/generateclasses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
DOTNET_CreateDumpDiagnostics: 1
DOTNET_CreateDumpVerboseDiagnostics: 1
DOTNET_EnableCrashReport: 1
JCOBRIDGE_LicensePath: ${{ secrets.JCOBRIDGE_ENCODED_2_5_21 }}
JCOBRIDGE_LicensePath: ${{ secrets.JCOBRIDGE_ENCODED_2_6_0 }}

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
Expand Down Expand Up @@ -56,7 +56,7 @@ jobs:
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase

- name: Create Jars for JNet
run: mvn "-DjcobridgeFolderName=binReflector" --file ./src/jvm/jnet/pom.xml --no-transfer-progress package
run: mvn "-DbinFolderName=binReflector" --file ./src/jvm/jnet/pom.xml --no-transfer-progress package
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
Expand Down
46 changes: 27 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ Its primary scope is to support other, public or internal, MASES Group projects:

The repository code and releases may contain bugs, the release cycle depends from critical discovered issues and/or enhancement requested from this or other projects.

Looking for the help of experts? MASES Group can help you design, build, deploy, and manage applications mixing .NET and JVM enabled languages.
Looking for the help of experts? MASES Group can help you design, build, deploy, and manage applications mixing .NET and JVM enabled languages.

---

## Scope of the project

This project aims to create a set of libraries and tools to direct access, from .NET, all the features available in the Java Platform, this is the counterpart of [JCOReflector](https://github.com/masesgroup/JCOReflector).
This project aims to create a set of libraries and tools to direct access, from .NET, all the features available in the Java Platform, this is the counterpart of [JCOReflector](https://github.com/masesgroup/JCOReflector).

There are many client libraries written to manage communication with Java. Conversely, this project use directly the Java packages giving more than one benefit:
There are many client libraries written to manage communication with Java. Conversely, this project use directly the Java packages giving more than one benefit:
* all implemented features are availables at no extra implementation costs, see [JNet usage](src/documentation/articles/usage.md);
* avoids any third party communication protocol implementation;
* access all features made available from Java platform.
* access all features made available from Java platform.

So, for example, do you want an `ArrayList`? Just write in C# a line of code like this:

Expand Down Expand Up @@ -62,7 +62,7 @@ This project adheres to the Contributor [Covenant code of conduct](CODE_OF_CONDU
* [JNet usage](src/documentation/articles/usage.md)
* [JNet performance tips](src/documentation/articles/performancetips.md)
* [JNet APIs extensibility](src/documentation/articles/API_extensibility.md)
* [JNet JVM callbacks](src/documentation/articles/jvm_callbacks.md)
* [JNet JVM callbacks](src/documentation/articles/jvm_callbacks.md)
* [JNet CLI usage](src/documentation/articles/usageCLI.md)
* [JNet Docker usage](src/documentation/articles/docker.md)
* [JNet Reflector usage](src/documentation/articles/usageReflector.md)
Expand All @@ -71,12 +71,12 @@ This project adheres to the Contributor [Covenant code of conduct](CODE_OF_CONDU

### News

* V1.4.8+: From version 1.4.8 there is a new project, named JNetReflector (still in development phase), able to build C# gateway classes from JARs containing the JVM classes, exactly the same [JCOReflector](https://github.com/masesgroup/JCOReflector) does for .NET in JVM.
* V1.4.8+: From version 1.4.8 there is a new project, named JNetReflector (still in development phase), able to build C# gateway classes from JARs containing the JVM classes, exactly the same [JCOReflector](https://github.com/masesgroup/JCOReflector) does for .NET in JVM.
* V1.4.9+: From version 1.4.9 there are two new projects:
* JNetPSCore: the core library for PowerShell development, it can be extended in other projects based on JNet;
* JNetPS: a PowerShell module to use JNet within a PowerShell shell.
* V1.5.2+: strong improvement of JNetReflector; it is used to generate almost all Java 11 classes available in the corresponding JNet version
* V1.5.3+: JNetReflector manages generics and almost all classes of Java SE 11 are covered: see [JNet Reflector usage](src/documentation/articles/usageReflector.md)
* V1.5.2+: strong improvement of JNetReflector; it is used to generate almost all Java 11 classes available in the corresponding JNet version
* V1.5.3+: JNetReflector manages generics and almost all classes of Java SE 11 are covered: see [JNet Reflector usage](src/documentation/articles/usageReflector.md)
* V2.0.0+: the most notable changes in this version are in:
* JNet: complete review of all classes based on automatic generation done using JNetReflector
* JNetReflector: improvements in many areas from generation of .NET interfaces to generics and where clauses, full story in https://github.com/masesgroup/JNet/issues/178
Expand All @@ -85,39 +85,47 @@ This project adheres to the Contributor [Covenant code of conduct](CODE_OF_CONDU
* JNetReflector: use `Java.Lang.String`, by default, instead of `string` (`System.String`) (see https://github.com/masesgroup/JNet/issues/363)
* V2.4.0+: the most notable changes in this version are in:
* JNet: review of classes based on latest updates of JNetReflector
* JNetReflector: use native types only when JVM counter-part is a native type (see https://github.com/masesgroup/JNet/issues/371)
* JNetReflector: can use signature to invoke JVM methods (see https://github.com/masesgroup/JNet/issues/374) or fallback to current behavior
* JNetReflector: use native types only when JVM counter-part is a native type (see https://github.com/masesgroup/JNet/issues/371)
* JNetReflector: can use signature to invoke JVM methods (see https://github.com/masesgroup/JNet/issues/374) or fallback to current behavior
* V2.5.0+: the most notable changes in this version are in:
* Tools and Docker images update to .NET 8
* JNetReflector: create side-by-side class on each listener used in case of pure JVM interface (see https://github.com/masesgroup/JNet/issues/393)
* JNetReflector: create side-by-side class on each listener used in case of pure JVM interface (see https://github.com/masesgroup/JNet/issues/393)
* JNet:
* review of classes based on latest updates of JNetReflector
* enhanced ByteBuffer management
* speed-up array/list conversion
* V2.5.11: updates to JCOBridge 2.5.21 and adds management of [CET](https://www.intel.com/content/www/us/en/developer/articles/technical/technical-look-control-flow-enforcement-technology.html) on recent Intel CPU due to [latest change on .NET 9](https://learn.microsoft.com/en-us/dotnet/core/compatibility/interop/9.0/cet-support): usage explanation on [this](src/documentation/articles/usage.md#intel-cet-and-jnet)
* V2.5.13: adds [JNetCLICore](https://www.nuget.org/packages/MASES.JNetCLICore) to help CLI operations across projects based on JNet
* V2.6.0: aligns to JCOBridge 2.6.* series

---

## Runtime engine

JNet uses [JCOBridge](https://www.jcobridge.com), and its [features](https://www.jcobridge.com/features/), to obtain many benefits:
* **Cyber-security**:
* [JVM](https://en.wikipedia.org/wiki/Java_virtual_machine) and [CLR, or CoreCLR,](https://en.wikipedia.org/wiki/Common_Language_Runtime) runs in the same process, but are insulated from each other;
* JCOBridge does not make any code injection into JVM;
* [JVM](https://en.wikipedia.org/wiki/Java_virtual_machine) and [CLR, or CoreCLR,](https://en.wikipedia.org/wiki/Common_Language_Runtime) runs in the same process, but are insulated from each other;
* JCOBridge does not make any code injection into JVM;
* JCOBridge does not use any other communication mechanism than JNI;
* .NET (CLR) inherently inherits the cyber-security levels of running JVM;
* **Direct access the JVM from any .NET application**:
* .NET (CLR) inherently inherits the cyber-security levels of running JVM;
* **Direct access to the JVM from any .NET application**:
* Any Java/Scala/Kotlin/... class can be directly managed;
* No need to learn new APIs: we try to expose the same APIs in C# style;
* No extra validation cycle on protocol and functionality: bug fix, improvements, new features are immediately available;
* Documentation is shared;
* **Dynamic code**: it helps to write a Java/Scala/Kotlin/etc seamless language code directly inside a standard .NET application written in C#/VB.NET: look at this [simple example](https://www.jcobridge.com/net-examples/dotnet-examples/) and [JNet APIs extensibility](src/documentation/articles/API_extensibility.md).

[JCOBridge 2.6.*](https://www.jcobridge.com) can be used for free without any obligations; you need to purchase a commercial license, or uninstall the software, if you have direct or indirect incomes from the product usage.

### JCOBridge resources

Have a look at the following JCOBridge resources:
- [Release notes](https://www.jcobridge.com/release-notes/)
- [Community Edition](https://www.jcobridge.com/pricing-25/)
- [Commercial Edition](https://www.jcobridge.com/pricing-25/)
- Latest release: [![JCOBridge nuget](https://img.shields.io/nuget/v/MASES.JCOBridge)](https://www.nuget.org/packages/MASES.JCOBridge)

|JCOBridge | 2.5.* series | 2.6.* series |
|:---: |:---: |:---: |
|JNet | > 1.5.* series | > 2.6.* series |
|Release notes|[Link](https://www.jcobridge.com/release-notes/)| [Link](https://www.jcobridge.com/release-notes/)|
|Community Edition|[Conditions](https://www.jcobridge.com/pricing-25/)|[Conditions](https://www.jcobridge.com/pricing-25/)|
|Commercial Edition|[Information](https://www.jcobridge.com/pricing-26/)|[Information](https://www.jcobridge.com/pricing-26/)|

Latest release: [![JCOBridge nuget](https://img.shields.io/nuget/v/MASES.JCOBridge)](https://www.nuget.org/packages/MASES.JCOBridge)
36 changes: 18 additions & 18 deletions src/documentation/articles/API_extensibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ _description: Describes how to extend available APIs with .NET suite for Java™
What to do if an API was not yet implemented? The simplest answer is: help us to make this product reacher :smile:
There is another answer which is not available with other products: Dynamic code and programmatically API access.

With **JCOBridge** a developer can use some properties to manage objects in the JVM.
Each JNet class implemented contains some methods and two properties: a direct and a dynamic accessor able to analyze the JVM class and executes the code.
With **JCOBridge** a developer can use some properties to manage objects in the JVM.
Each JNet class implemented contains some methods and two properties: a direct and a dynamic accessor able to analyze the JVM class and executes the code.
So it is not necessary at all to have the methods be ready to be used.

Let's go to show some possible conditions analyzing the `Hashtable` class (code at https://github.com/masesgroup/JNet/blob/master/src/net/JNet/Java/Util/Hashtable.cs).
Expand All @@ -22,7 +22,7 @@ The class has a single ready made method:
public void Put(K key, V value) => IExecute("put", key, value);
```

This is a void method, using **IExecute** the user of the library can invoke the `Put` method on the class and execute the Java counterpart.
This is a void method, using **IExecute** the user of the library can invoke the `Put` method on the class and execute the Java counterpart.
The developer can, anyway, invoke the `put` method directly from the instance of the `Hashtable` class using two different paradigms: **direct** or **dynamic** access.
The `put` method can be replaced with any method (with or without parameters) of the `Hashtable` class.

Expand Down Expand Up @@ -53,7 +53,7 @@ data.put("a", "b");
var isEmpty = data.isEmpty();
```

The `Hashtable`, and any other ready made class of the library, supports the **dynamic** access to the methods available in Java side.
The `Hashtable`, and any other ready made class of the library, supports the **dynamic** access to the methods available in Java side.
The previous example demostrates the behavior.

## When a class is not available
Expand All @@ -64,7 +64,7 @@ In a more complex scenario the method can return back objects or can accept inpu

To discuss this case we use another class: the [AWT Panel](https://docs.oracle.com/javase/8/docs/api/java/awt/Panel.html), implemented in [Java.Awt.Panel](https://github.com/masesgroup/JNet/blob/master/src/net/JNet/Java/Awt/Panel.cs).
The .NET class does not have any implemented method: we discuss about [createVolatileImage](https://docs.oracle.com/javase/8/docs/api/java/awt/Component.html#createVolatileImage-int-int-) inherited from the base class `Component`.
The method returns a [VolatileImage](https://docs.oracle.com/javase/8/docs/api/java/awt/image/VolatileImage.html) which is not yet implemented; a solution on this problem is to use directly the `createVolatileImage` Java method like the following code snippet does:
The method returns a [VolatileImage](https://docs.oracle.com/javase/8/docs/api/java/awt/image/VolatileImage.html) which is not yet implemented; a solution on this problem is to use directly the `createVolatileImage` Java method like the following code snippet does:

```C#
Java.Awt.Panel panel = new();
Expand All @@ -74,7 +74,7 @@ var isContentLost = volImage.contentsLost(); // the returned object is a bool re

```

The example above uses the classes `VolatileImage` and `BufferedImage` which are not implemented yet: the classes exists in JVM and can be accessed.
The example above uses the classes `VolatileImage` and `BufferedImage` which are not implemented yet: the classes exists in JVM and can be accessed.

### Input and Return class are not available

Expand All @@ -89,12 +89,12 @@ var isContentLost = volImage.contentsLost(); // the returned object is a bool re

```

In the above example the class `ImageCapabilities` is not implemented yet. Since it exists in the JVM it can be allocated and used.
In the above example the class `ImageCapabilities` is not implemented yet. Since it exists in the JVM it can be allocated and used.
Each object, like `Panel` instance, exposes (hidden in the editor) two properties:
* **JVM** which access the JVM using methods;
* **DynJVM** which access the JVM using the Dynamic engine.
* **JVM** which access the JVM using methods;
* **DynJVM** which access the JVM using the Dynamic engine.

Using the listed properties it is possible to instruct the JVM about the action to be done.
Using the listed properties it is possible to instruct the JVM about the action to be done.

### Anything is not available

Expand All @@ -109,12 +109,12 @@ var isContentLost = volImage.contentsLost(); // the returned object is a bool re

```

The example above consider that even the class `Panel` is not implemented yet. Since it exists in the JVM it can be allocated and used.
The example above consider that even the class `Panel` is not implemented yet. Since it exists in the JVM it can be allocated and used.
In previous chapter the tutorial reports about two hidden properties in each object; the properties on each class are just an useful reference to the real one available in `JCOBridge.Global`:
* **JVM** which access the JVM using methods;
* **DynJVM** which access the JVM using the Dynamic engine.
* **JVM** which access the JVM using methods;
* **DynJVM** which access the JVM using the Dynamic engine.

Using the properties it is possible to instruct the JVM about the action to be done.
Using the properties it is possible to instruct the JVM about the action to be done.

### Call a method dynamically

Expand All @@ -130,11 +130,11 @@ var result = panel.DynInstance.getLayout(); // this line invokes dynamically the
As exposed before, each object, like `Panel` instance, exposes (hidden in the editor) two properties.

Explaining the code:
* The first line creates a JVM object in C# style: `Container` lives in the CLR and has its counterpart in the JVM.
* The first line creates a JVM object in C# style: `Container` lives in the CLR and has its counterpart in the JVM.
* The `result` is a **dynamic** object that can be used to extract data or invokes other methods on the result of `getLayout` which is an object of type `LayoutManager`.

## API exendibility limitation

Starting from the assumption that JCOBridge does not make any code injection, or compilation, within JVM side, the actual limitation is related to something missing within the JVM.
In the [JVM callbacks](jvm_callbacks.md) article there is an explanation of how works callbacks.
**The callback feature needs a concrete class in the JVM and if it does not exist there is no way to use it from JNet.**
Starting from the assumption that JCOBridge does not make any code injection, or compilation, within JVM side, the actual limitation is related to something missing within the JVM.
In the [JVM callbacks](jvm_callbacks.md) article there is an explanation of how works callbacks.
**The callback feature needs a concrete class in the JVM and if it does not exist there is no way to use it from JNet.**
4 changes: 2 additions & 2 deletions src/documentation/articles/commandlineswitch.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ Plus it accepts from:
* **JCOBridge**:
* All command-line switches of JCOBridge available at https://www.jcobridge.com/net-examples/command-line-options/

## JVM identification
## JVM identification

One of the most important command-line switch is **JVMPath** and it is available in [JCOBridge switches](https://www.jcobridge.com/net-examples/command-line-options/): it can be used to set-up the location of the JVM library if JCOBridge is not able to identify a suitable JRE installation.
One of the most important command-line switch is **JVMPath** and it is available in [JCOBridge switches](https://www.jcobridge.com/net-examples/command-line-options/): it can be used to set-up the location of the JVM library if JCOBridge is not able to identify a suitable JRE installation.
If a developer is using KNet within its own product it is possible to override the **JVMPath** property with a snippet like the following one:

```c#
Expand Down
2 changes: 1 addition & 1 deletion src/documentation/articles/currentstate.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ This release comes with some ready made classes:
* Manually made some classes, or extended some of reflected one, due to limitations of JNetReflector
* If something is not available use [API extensibility](API_extensibility.md) to cover missing classes.
* JNetCLI: added REPL shell, run Main-Class and execute C# scripts
* JNetReflector: builds listeners and reflects Java classes with constructor, methods, fields, conversion operators and documentation
* JNetReflector: builds listeners and reflects Java classes with constructor, methods, fields, conversion operators and documentation
* JNetPSCore: base implementation for JNetPS
* JNetPS: some PowerShell cmdlets
Loading
Loading