Converting java based plugins to 64-bit

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: white, Hacker, petermad, Stefan2

User avatar
nsp
Power Member
Power Member
Posts: 1803
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: Converting java based plugins to 64-bit

Post by *nsp »

moisescastellano wrote: 2021-12-18, 09:28 UTC 2nsp
The visual studio project is the one Handel created (http://java.totalcmd.net/V1.7/Projects.tgz), but read above in this thread the changes Ghisler made to recompile for 64bit. Also he sent me the project with the changes in configuration via mail, you can ask him or contact me (see the GitHub page in the previous post for contact).

However probably you dont need it: the dll for wlx64 is the same for all plugins (also for wcx64, wdx64, wfx64). You can take it from any of the examples updated to 64-bit I uploaded at https://github.com/moisescastellano/tcmd-java-plugin/blob/main/examples_64bit.md

Specifically the jad decompiler plugin by Handel works fine and is updated at: https://github.com/moisescastellano/tcmd-java-plugin/raw/main/examples/v2.1/JADDemo.zip
With TotalCommander 10.0 (and probably since 9) the wlx plugin is broken as the dimension are captured but not the position (probably because it get a relative rectangle instead of absolute). This has to be fixed probably in the listplug.cpp function void JNICALL Java_plugins_wlx_WLXPluginAdapter_setSize.
moisescastellano
Junior Member
Junior Member
Posts: 36
Joined: 2021-12-05, 19:11 UTC

Re: Converting java based plugins to 64-bit

Post by *moisescastellano »

nsp wrote: 2021-12-19, 09:07 UTC With TotalCommander 10.0 (and probably since 9) the wlx plugin is broken as the dimension are captured but not the position (probably because it get a relative rectangle instead of absolute). This has to be fixed probably in the listplug.cpp function void JNICALL Java_plugins_wlx_WLXPluginAdapter_setSize.
What you mean, broken? You mean some specific functionality or behaviour regarding the position?
As I said the jadDemo (wlx plugin) is working, here a screenshot.

Also other lister plugin examples work fine.

I am using TC10.00 x64

Update: I also checked under TC32, works fine. However I found 2 issues:

- if you have both TCx64 and TCx32 installed, plugins are installed under TCx64, but the javalib is searched under %COMMANDER% variable, which TCx32 stablishes to its own dir. Not a big problem, as I guess most people have just one TC; can be solved copying plugin dir including javalib.

- The JadDemo plugin is much slower in TCx64, even when the JRE is the same. The only reason I can think of, is that in order to recompile the dll64, Ghisler
had to disable optimizations, it crashes with optimizations on
User avatar
nsp
Power Member
Power Member
Posts: 1803
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: Converting java based plugins to 64-bit

Post by *nsp »

moisescastellano wrote: 2021-12-19, 19:27 UTC
nsp wrote: 2021-12-19, 09:07 UTC With TotalCommander 10.0 (and probably since 9) the wlx plugin is broken as the dimension are captured but not the position (probably because it get a relative rectangle instead of absolute). This has to be fixed probably in the listplug.cpp function void JNICALL Java_plugins_wlx_WLXPluginAdapter_setSize.
What you mean, broken? You mean some specific functionality or behaviour regarding the position?
As I said the jadDemo (wlx plugin) is working, here a screenshot.

Also other lister plugin examples work fine.

I am using TC10.00 x64

Update: I also checked under TC32, works fine. However I found 2 issues:

- if you have both TCx64 and TCx32 installed, plugins are installed under TCx64, but the javalib is searched under %COMMANDER% variable, which TCx32 stablishes to its own dir. Not a big problem, as I guess most people have just one TC; can be solved copying plugin dir including javalib.

- The JadDemo plugin is much slower in TCx64, even when the JRE is the same. The only reason I can think of, is that in order to recompile the dll64, Ghisler
had to disable optimizations, it crashes with optimizations on
The lister plugin is not working correctly in my side as the frame is not inside the lister/quickview window.. (Frame is there but not placement).

The root cause is SetParent function fail with error 5023 this is due to not compatible dpi awareness between the plugin windows and the lister.
The jvm have DPI_AWARENESS_SYSTEM_AWARE and Tlister have DPI_AWARENESS_PER_MONITOR_AWARE context.

=-Edit-= If DpiPerScreen=1 in wincmd.ini we have wrong berhaviour, if DpiPerScreen=0 all is OK for the plugin but the per monitor setting is lost.


About the 32/64bit in single installation, we could change java.cpp to read a JVM64 section instead of JVM for 64bit plugins or key JVM_DLL64 and JVM_HOME64.
User avatar
nsp
Power Member
Power Member
Posts: 1803
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: Converting java based plugins to 64-bit

Post by *nsp »

I can have wlx attached to lister window if TC thread is able to handle DPI_HOSTING_BEHAVIOR_MIXED before creating lister window... Unfortunatelly lister window is created before call to plugin so i cannot change for first run :( but all others seems to work fine.
A startup call using a dummy wdx could be done to force the MIXED behavior on TC thread but this is not the cleanest way...

@GhislerAutor
The cpp call is SetThreadDpiHostingBehavior(DPI_HOSTING_BEHAVIOR_MIXED) and i do not know if you could set it before creating TCLister ?
moisescastellano
Junior Member
Junior Member
Posts: 36
Joined: 2021-12-05, 19:11 UTC

Re: Converting java based plugins to 64-bit

Post by *moisescastellano »

nsp wrote: 2021-12-20, 11:46 UTC The lister plugin is not working correctly in my side as the frame is not inside the lister/quickview window.. (Frame is there but not placement).
OK, that also happens to me, I just did not realize that was an error.

Happy to see you are tackling this, so we can have this neat little piece of software back to life!

I will be reporting more updates on the Java side.
moisescastellano
Junior Member
Junior Member
Posts: 36
Joined: 2021-12-05, 19:11 UTC

Re: Converting java based plugins to 64-bit

Post by *moisescastellano »

I have developed a new plugin based on this Java interface!
It is another packer plugin, this one is a java class decompiler, check the post:
Java Decompiler TC Plugin
moisescastellano
Junior Member
Junior Member
Posts: 36
Joined: 2021-12-05, 19:11 UTC

Re: Converting java based plugins to 64-bit

Post by *moisescastellano »

A new version of the Java Plugin Interface (2.2) has been uploaded to:
- Totalcmd.net
- the Github project

changes in this version:
v2.2 - 2021-dec-30
  • Java plugin interface is now hosted at Github pages(https://moisescastellano.github.io/tcmd-java-plugin/)
  • Source code is now available at Github(https://github.com/moisescastellano/tcmd-java-plugin)
    - src\vc-project: Visual C++ source for creating the dll (the plugin core is this dll renamed to wlx, wfx, wdx or wcx)
    - src\tc-apis: The Java plugin API source code
    - src\plugins: Java source code for each example plugin, previously sparsed in multiple .jar files
    - Frozen release-1.7 branch is intended to keep **original code by Ken Handel**, java plugin interface version 1.7.
    - More info regarding this source code / git branches / folder structure at [src/README.md file](src/README.md)
  • Further testing done on the [example plugins](https://moisescastellano.github.io/tcmd-java-plugin/examples_64bit)
    - ImageContent plugin was missing swt library
  • Logging is updated to SLF4J for each plugin (previously was based on deprecated Apache commons-logging implementation).
    - Logging now works for Log4j2 via SLF4J.
    - Logging is disabled by default, any logging implementation has been removed from the plugin itself.
    - Documentation about [how to configure logging for plugins](https://github.com/moisescastellano/tcmd-java-plugin/blob/main/logging.md).
  • PluginClassLoader was incomplete (missing e.g. findResources implementation). It has now been completed
Complete history of changes here

Enjoy and Happy New Year 2022!
moisescastellano
Junior Member
Junior Member
Posts: 36
Joined: 2021-12-05, 19:11 UTC

Re: Converting java based plugins to 64-bit

Post by *moisescastellano »

There are now a couple (closely related) issues reported regarding this Java plugin interface, which are difficult to solve for myself as they are Visual C++ related, which I am not familiar with.

For some JDK/JRE versions the plugin has a hard time to find or load the Java Virtual Machine.

The first one is the error "JRE is not installed" when finding the library, that the plugin searchs in two ways described in the issue.

The second one is plugin complains "LoadLibrary Failed / Starting Java Virtual Machine failed". Specific JREs failing are reported in the issue.

If you are giving a try to the Java plugin interface or any of its plugins, some working (Oracle JREs) versions are: jre1.8.0_211, jre-8u311-windows-x64

If you are a developer and can help, the JVM search code is performed here: https://github.com/moisescastellano/tcmd-java-plugin/blob/main/src/vc-project/Total%20Commander%20Java%20Plugin/java.cpp
moisescastellano
Junior Member
Junior Member
Posts: 36
Joined: 2021-12-05, 19:11 UTC

Re: Converting java based plugins to 64-bit

Post by *moisescastellano »

A new version of the Java Plugin Interface (2.3) has been uploaded to:
- Totalcmd.net
- Github project
- Github pages

v2.3 - 2022-jan-14 - changes in this version: Complete history of changes here
Post Reply