This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information

Category: Development

Adding new paths for native libraries at runtime in Java

If you want to add some native libraries at runtime, it was tricky with Java 8+:

This was a valid solution:

final Field fldUsrPaths = ClassLoader.class.getDeclaredField("usr_paths");
fldUsrPaths.setAccessible(true);
 
//get array of paths
final String[] saPath = (String[])fldUsrPaths.get(null);
 
//check if the path to add is already present
for (String path : saPath)
{
    if (path.equals(pPath))
    {
        return;
    }
}
 
//add the new path
final String[] saNewPaths = Arrays.copyOf(saPath, saPath.length + 1);
saNewPaths[saNewPaths.length - 1] = pPath;
fldUsrPaths.set(null, saNewPaths);

Since Java 10+ it's not possible anymore, because of: JDK-8210522
Some details from Stackoverflow

If someone still needs a solution for Java 10+, here it is:

Lookup cl = MethodHandles.privateLookupIn(ClassLoader.class, MethodHandles.lookup());
VarHandle usr_paths = cl.findStaticVarHandle(ClassLoader.class, "usr_paths", String[].class);
String[] path = (String[])usr_paths.get();

...

usr_paths.set(new String[] {"A", "B"});

This code won't work if you are using Java 8. If you want support for e.g. Java < 10, simply use reflection :)
Sounds simple, but it is not simple.....

Here's a working solution: toPDF project (search for addLibraryPath(String pPath)).

The code in detail:

Class<?> clsMHandles = Class.forName("java.lang.invoke.MethodHandles");
       
Method mStaticLookup = clsMHandles.getMethod("lookup");
Object oStaticLookup = mStaticLookup.invoke(null);

Method mLookup = clsMHandles.getMethod("privateLookupIn", Class.class, Class.forName("java.lang.invoke.MethodHandles$Lookup"));
Object oLookup = mLookup.invoke(null, ClassLoader.class, oStaticLookup);

Method mFindStatic = oLookup.getClass().getMethod("findStaticVarHandle", Class.class, String.class, Class.class);

Object oVarHandle = mFindStatic.invoke(oLookup, ClassLoader.class, "usr_paths", String[].class);

//MethodHandle mh = MethodHandles.lookup().findVirtual(VarHandle.class, "get", MethodType.methodType(Object.class));
//mh.invoke(oVarHandle);

Method mFindVirtual = oStaticLookup.getClass().getMethod("findVirtual", Class.class, String.class, Class.forName("java.lang.invoke.MethodType"));

Class<?> clsMethodType = Class.forName("java.lang.invoke.MethodType");
Method mMethodType = clsMethodType.getMethod("methodType", Class.class);

Object oMethodHandleGet = mFindVirtual.invoke(oStaticLookup, Class.forName("java.lang.invoke.VarHandle"), "get", mMethodType.invoke(null, Object.class));

Method mMethodHandleGet = oMethodHandleGet.getClass().getMethod("invokeWithArguments", Object[].class);

String[] saPath = (String[])mMethodHandleGet.invoke(oMethodHandleGet, new Object[] {new Object[] {oVarHandle}});

//check if the path to add is already present
for (String path : saPath)
{
    if (path.equals(pPath))
    {
        return;
    }
}

//add the new path
final String[] saNewPaths = Arrays.copyOf(saPath, saPath.length + 1);
saNewPaths[saNewPaths.length - 1] = pPath;

//MethodHandle mh = MethodHandles.lookup().findVirtual(VarHandle.class, "set", MethodType.methodType(Void.class, Object[].class));
//mh.invoke(oVarHandle, new String[] {"GEHT"});

mMethodType = clsMethodType.getMethod("methodType", Class.class, Class.class);

Object oMethodHandleSet = mFindVirtual.invoke(oStaticLookup, Class.forName("java.lang.invoke.VarHandle"), "set", mMethodType.invoke(null, Void.class, Object[].class));

Method mMethodHandleSet = oMethodHandleSet.getClass().getMethod("invokeWithArguments", Object[].class);

mMethodHandleSet.invoke(oMethodHandleSet, new Object[] {new Object[] {oVarHandle, saNewPaths}});

Not simple!!!

Summarized: It's not easy but it's still possible. So.... why are things getting more and more complex?

VisionX 5.4 Update release is available

VisionX 5.4.2450 is available!

It's a small update release with following improvements:

  • MySql database support

    We fixed a problem with app export (from embedded PostgreSql) and re-import into a MySql database. It wasn't possible to configure combobox columns.

  • Popup Menu button click

    Sometimes, a click on the arrow of a popup menu button, didn't show the popup and triggered the button action instead.

  • Screen generation

    A new screen with only one table was generated with an additional "white" panel.

  • Filter AddOn update

    We improved the Filter AddOn and now support And/Or grouping. It's also possible to save and load filter settings.

    Some impressions:

    Filter AddOn

    Filter AddOn

    Load settings

    Load settings

  • Filter Editor API

    We improved our Filter Editor API. It's now possible to define the Full-text Filter column names and also which column names can be filtered in general. It's possible to group filter editors by condition (or, and, ...). This enhancement is relevant for developers.

VisionX 5.4 is available

VisionX 5.4.1835 is available!

It's a great release with big changes.

The new VisionX version got updates of used open source libraries. It runs with openJDK 12 and supports openJDK 14. It comes with awesome responsive UI support for desktop, web and mobile. We support our brand new mobile UI which is still under development.

What's different?

  • New MorphPanel with full responsive support

    This feature is available for Desktop, Web and Mobile devices. Create only one screen to support all targets.

    Responsive for Desktop

    Responsive for Desktop

    Web settings

    Web settings

    Mobile settings

    Mobile settings

  • Responsive option for Panels

    Simply en/disable the responsive feature for single panels.

    Responsive option

    Responsive option

  • MorphPanel navigation bar

    The MorphPanel shows a small navigation bar directly in the screen. You can use this bar to switch between the tabs without opening the customizer every time.

    Morph Panel navigation

    Morph Panel navigation

  • New work-screen wizard

    We have 4 types of screens: Table with Detail form, Table, Form, Empty. Each type has different layout options for Web, Desktop, Mobile and Universal. The difference are gaps and margins and default settings of elements. Some layouts include full-text search and some don't include search options.

    New screen wizard

    New screen wizard

  • New customizable screen generators

    The screen generators are customizable for developers. Simply create your own or extend an existing generator and use it directly in VisionX. Simply create your own definition file like this one:

    <?xml version="1.0" encoding="UTF-8"?>

    <generator>
      <group text="Table with detail form"
             image="/c/s/v/i/w/w/category_tableform.png">
        <entry class="com.sibvisions.visionx.uigenerator.WebTableFormUIGenerator"
               text="Web layout"
               image="/c/s/v/i/w/w//group_web.png" />
        <entry class="com.sibvisions.visionx.uigenerator.MobileTableFormUIGenerator"
               text="Mobile layout"
               image="/c/s/v/i/w/w//group_mobile.png" />
        <entry class="com.sibvisions.visionx.uigenerator.TableFormUIGenerator"
               text="Desktop layout"
               image="/c/s/v/i/w/w//group_desktop.png" />
        <entry class="c.s.visionx.uigenerator.UniversalTableFormUIGenerator"
               text="Universal layout"
               image="/c/s/v/i/w/w//group_universal.png" />
      </group>
    </generator>

  • Live Preview without any differences

    We improved our UI for browsers. New layouts, better performance and same features.

  • Shared folder support

    An awesome new feature is the shared folder support for your projects if you are a developer. Simply put your POJOs or Beans in the new shared folder and use this classes in your client or server classes.

  • New domain management

    Change pre-defined or create custom datatypes. The screen is available in VisionX' Administration menu.

    Domain management

    Domain management

  • Support for latest Workflow AddOn (3.0)
  • Performance improvement of Designer

This is how the responsive mode works on Desktop

Responsive mode

Some impressions of our new mobile client are available here

The download area already contains links to latest VisionX binaries.

Please report any problems as usual and have fun with VisionX.

VisionX 5.3 is available

VisionX 5.3.2 is available!

It's a minor update release with big changes.
The release got updates of open source libraries like JVx and Vaadin UI.

But the biggest changes are the integrated Java 12 support. VisionX 5.3 comes with and runs under Java 12 (openJDK).

What's different?

  • Performance improvement of Designer
  • Performance improvement of HTML5 UI
  • New App Elements

    Save All Changes, Reload All Changes, Advanced Panel and Advanced Group Panel

  • REST documentation contains admin services
  • Bundled open JDK 12
  • Support for latest Workflow AddOn (1.5)

The download area already contains links to latest VisionX binaries.

Please report any problems as usual and have fun with VisionX.

Eclipse 2018.12 with ANT and JRE 6

The support for ANT and JRE6 with Eclipse 2018.12.

The plugin was created for:

Version: 2018-12 (4.10.0)
Build id: 20181214-0600

Don't forget the -clean start (read the original article for more details)!

One more thing you should do:

Photon includes ANT > 1.10. This version requires Java 8. In order to use Java 6, you have to download ANT 1.9.x. Simply download ANT and set the ANT Home to your version, via

(Window >>) Preferences >> ANT >> Runtime >> Ant Home...

If you try to use the bundled ANT with JRE 6, it will fail with an Exception.

Download the plugin from here. It works for us - no warranty!

More Details: Eclipse Photon with ANT and JRE6.

VisionX 5 update Release-3

VisionX 5.2.27 is available!

It's a small bugfix release with an update of open source libraries like JVx and Vaadin UI.

What's different?

  • Group Panel visibility now working in Browser
  • Group Panel text color now working in Browser
  • Set additional css class names for labels and checkbox editors
  • It's now easier to extend search behavior of NavigationTable
  • Checkbox alignment fixed in Browser
  • Support for latest Workflow AddOn

The download area already contains links to latest VisionX binaries.

Please report any problems as usual and have fun with VisionX.

VisionX 5 update Release-2

We're happy to anounce that VisionX 5.1.221 is available!

It's a bigger update release of VisionX 5.1.8 with with some new "visible" features and many awesome new features under the hood.

Let's start with important bug fixes

  • Popup Menu in Browser application

    A custom Popup Menu in Browser applications was always empty. This problem was fixed in an OpenSource library and is now available in VisionX applications.

  • Timeout with customizer changes

    If VisionX timeout while a customizer with changed values was open, the timeout operation failed and VisionX was unusable.

  • Element selection not always working

    Sometimes it wasn't possible to select elements if they where behind other elements.

  • Database procedure and function calls with more than 10 parameters

    It's now supported to call database procedures and functions with max. 100 parameters.

  • External CSS file detection

    VisionX had some path problems with Linux and MacOS to find the external CSS file for browser applications.

  • Fixed painting of overlays (MacOS)

    The position of e.g. VisionX Guides wasn't correct. The small numbers were wrong positioned.

  • Workflow integration

    The workflow engine wasn't always started correctly and not in the correct window.

  • All bugfixes of JVx, VaadinUI and other OpenSource libraries

What's new?

  • A new Workflow AddOn
  • Swagger documentation

    The documentation now contains information about sub storages (used in drop down boxes) and default admin services. It's now easier to grant access to external applications based on the REST API of your application.

  • Java 9+

    It's now possible to use e.g. Java 11 as runtime for VisionX.

  • Storage editor for Developers

    Out storage Editor was only available if you bought the Forms license. Now all users with Development license will be able to use the Storage Editor. The storage editor is a feature which allows you to change the database query of a table, directly in VisionX.

  • Prompt/Placeholder support
  • Better layouting in browser application

    We improved the layouting in our browser applications and also improved scrolling of panels.

  • Experimental (Early Access) Features

    We added some experimental features in this release: QR code authentication, Spnego (Active Directory) authentication base support (needs an additional AddOn), SSO authentication feature for REST services (bypass option).

    This features are available for interested developers. Simply talk to your contact person.

The download area already contains links to latest VisionX binaries.

Please report any problems as usual and have fun with VisionX.

JVx 2.8 is available

We're happy to announce that JVx 2.8 is available. It's a big release with lots of important bug fixes and some awesome new features. The last release of JVx was in January. It was version 2.7 which was more or less a small bugfix release with few new features. We took more time for JVx 2.8 to make it awesome.

What's new?

  • Placeholder/Prompt support

    This feature is available for input fields and cell editors. Simply enable this feature:

    editor.setPlaceholderVisible(true);
    editor.setPlaceholder("PLACEHOLDER");

    to get

    Prompt support

    Prompt support

  • New popup menu button

    This new button reduces the visible components. It's a must have for modern applications:

    Menu button

    Menu button

  • Savepoints for transaction handling in PostgreSql
  • Components have a unique name

    This is an important feature fore UI tests and our headless UI as well. It's now possible to address components in vaadin UI by their id to apply custom css.

  • Configurable REST services
  • Mac OS UI improvements

The full changelog is available here.

Start with JVx

New VisionX Demo application is available

Our VisionX solution store got a new demo application. It's a demo for calculated columns. A calculated column is a virtual column, filled with custom content.

Simply install the application from our solution store:

Demo application - Solution store

Demo application - Solution store

The application has 3 workscreens. One demonstrates client-side calculated columns, the second one server-side calculated columns and the third screen demonstrates calculated columns directly in the database. You have different options to use calculated columns, simply check what you prefer.

JVx' REST interface Update for JVx 2.8

Our generic REST interface in JVx is well documented and different examples for different technologies are available. The generic approach itself is smart but not super specific because the implementation follows the CoC paradigm. It's awesome for "REST out-of-the-box" without additional coding effort, but the flexibility is sometimes missing.

We tried to break some of this restrictions and get more flexibility. Here is a list of new features to explain some details:

  • Fetch on demand

    The old implementation always returned all records from the database. It wasn't possible to implement paging or lazy loading. To solve this problem, we introduced new request parameters:

    _firstRow
    _maxRows

    With _firstRow (starts from 0) you define the start record number. The _maxRows defines the amount of records for the resultset, e.g. start from 0 and return max. 20 records, start from 20 and return 20 records

  • Configure visible columns

    The old implementation returned the same column list for the REST call and the GUI/frontend. But sometimes the REST call should return a different list of columns because some internal columns aren't relevant or should be hidden. The new implementation got a new property in the metadata object: visibleColumnNames. If you set this property, the REST interface will return only the configure columns. The GUI won't recognize the new property because GUI controls have own visible column properties.

  • Actions with Array parameters

    The old implementation didn't support simple Arrays like BigDecimal[] as parameter types for action calls. Only List was supported. The new implementation supports Arrays but it's not possible to mix Array and List parameters. An example:

    //valid
    public String createPerson(String[] name, String[] title)
    //valid
    public String createPerson(List<String> name, List<String> title)
    //invalid
    public String createPerson(String[] name, List<String> title)
  • New admin zone

    We introduced a new admin zone for generic admin options. The URLs are:

    http://.../services/rest/APPLICATION_NAME/_admin/ACTION_NAME
    http://.../services/rest/APPLICATION_NAME/_admin/ACTION_NAME/ACTION_PARAM

    Currently, we support following actions (POST requests): changePassword, testAuthentication

    The request needs a JSON object with username, oldpassword, newpassword or password properties.

  • Configurable zones

    We now allow custom zones. The current default zones are:

    http://.../services/rest/APPLICATION_NAME/_admin/...
    http://.../services/rest/APPLICATION_NAME/LIFECYCLE_CLASS/data/OBJECT_NAME/...
    http://.../services/rest/APPLICATION_NAME/LIFECYCLE_CLASS/action/ACTION_NAME/...
    http://.../services/rest/APPLICATION_NAME/LIFECYCLE_CLASS/object/OBJECT_NAME/...

    The zone names are: _admin, data, action, object
    It's possible to set custom names with following parameters in the deployment descriptor: zone.admin, zone.data, zone.action, zone.object

  • Hide object names

    If you want to hide the object name(s), e.g.

    https://.../demoerp/services/rest/DemoERP/Customers/data/customer/

    The URL contains the Lifecycle Name (Customers) and the object name (customer). Both are easy to understand. In this example, we return the customer list from our customers object. If you want to use different names, it's possible to change the name in the lifecycle object code, e.g.

    @Replacement(name="business")
    public class Customers extends Session
    {
        @Replacement(name="clist")
        public IStorage getCustomer()
        {
            ...
        }
    }

    With above code, it'll be possible to request:

    https://.../demoerp/services/rest/DemoERP/business/data/clist/

The updated implementation is still a generic solution but it's now more flexible than before and should help you to offer new services. To use the new features, simply use our nightly JVx builds.