From 1a2f7fc32b28ffea718fcbc14403c381998d1842 Mon Sep 17 00:00:00 2001 From: Stepan Usatiuk Date: Thu, 26 Jun 2025 08:03:35 +0200 Subject: [PATCH] dump 3 --- launcher/CMakeLists.txt | 1 - launcher/backend/CMakeLists.txt | 12 ++- .../backend/include_public/DhfsInstance.hpp | 23 +++-- .../include_public/DhfsStartOptions.hpp | 25 +++++ .../backend/include_public/DhfsWxProcess.hpp | 24 +++++ launcher/backend/src/DhfsInstance.cpp | 59 +++++++----- launcher/backend/src/DhfsStartOptions.cpp | 31 +++++++ launcher/backend/src/DhfsWxProcess.cpp | 14 +++ launcher/gui/CMakeLists.txt | 2 + launcher/gui/src/DhfsGuiInstance.cpp | 23 +++++ launcher/gui/src/DhfsGuiInstance.hpp | 25 +++++ launcher/gui/src/GLauncherApp.cpp | 14 ++- launcher/gui/src/GLauncherApp.h | 2 + launcher/gui/src/LauncherAppMainFrame.cpp | 62 ++++++++++--- launcher/gui/src/LauncherAppMainFrame.h | 15 ++- launcher/gui/src/launcher.fbp | 91 +++++++++++++++---- launcher/libjvm_wrapper/CMakeLists.txt | 12 --- .../include_public/LibjvmWrapper.hpp | 34 ------- launcher/libjvm_wrapper/src/LibjvmWrapper.cpp | 59 ------------ launcher/utils/src/Exception.cpp | 2 - 20 files changed, 362 insertions(+), 168 deletions(-) create mode 100644 launcher/backend/include_public/DhfsStartOptions.hpp create mode 100644 launcher/backend/include_public/DhfsWxProcess.hpp create mode 100644 launcher/backend/src/DhfsStartOptions.cpp create mode 100644 launcher/backend/src/DhfsWxProcess.cpp create mode 100644 launcher/gui/src/DhfsGuiInstance.cpp create mode 100644 launcher/gui/src/DhfsGuiInstance.hpp delete mode 100644 launcher/libjvm_wrapper/CMakeLists.txt delete mode 100644 launcher/libjvm_wrapper/include_public/LibjvmWrapper.hpp delete mode 100644 launcher/libjvm_wrapper/src/LibjvmWrapper.cpp diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index e0017230..ac352638 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -29,6 +29,5 @@ if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") endif () add_subdirectory(utils) -add_subdirectory(libjvm_wrapper) add_subdirectory(backend) add_subdirectory(gui) diff --git a/launcher/backend/CMakeLists.txt b/launcher/backend/CMakeLists.txt index 96d81d2d..6268a628 100644 --- a/launcher/backend/CMakeLists.txt +++ b/launcher/backend/CMakeLists.txt @@ -1,9 +1,19 @@ +find_package(wxWidgets REQUIRED COMPONENTS base) +if (wxWidgets_USE_FILE) # not defined in CONFIG mode + include(${wxWidgets_USE_FILE}) +endif () + add_library(backend src/DhfsInstance.cpp include_public/DhfsInstance.hpp + src/DhfsStartOptions.cpp + include_public/DhfsStartOptions.hpp + src/DhfsWxProcess.cpp + include_public/DhfsWxProcess.hpp ) target_include_directories(backend PRIVATE include) target_include_directories(backend PUBLIC include_public) -target_link_libraries(backend PUBLIC libjvm_wrapper utils) +target_link_libraries(backend PRIVATE ${wxWidgets_LIBRARIES}) +target_link_libraries(backend PUBLIC utils) diff --git a/launcher/backend/include_public/DhfsInstance.hpp b/launcher/backend/include_public/DhfsInstance.hpp index 8f854685..2f773c2e 100644 --- a/launcher/backend/include_public/DhfsInstance.hpp +++ b/launcher/backend/include_public/DhfsInstance.hpp @@ -5,9 +5,14 @@ #ifndef DHFSINSTANCE_HPP #define DHFSINSTANCE_HPP -#include +#include #include #include +#include +#include + +#include "DhfsStartOptions.hpp" +#include "DhfsWxProcess.hpp" enum class DhfsInstanceState { RUNNING, @@ -18,19 +23,25 @@ class DhfsInstance { public: DhfsInstance(); - ~DhfsInstance(); + virtual ~DhfsInstance(); DhfsInstanceState state(); - void start(const std::string& mount_path, const std::vector& extra_options); + void start(DhfsStartOptions start_options); void stop(); + virtual void OnTerminate(int pid, int status) = 0; + + virtual void OnRead(std::string s) = 0; + +protected: + std::unique_ptr process = std::make_unique(*this); + private: DhfsInstanceState _state = DhfsInstanceState::STOPPED; - - JavaVM* _jvm = nullptr; - JNIEnv* _env = nullptr; + std::thread _readThread; + std::mutex _mutex; }; diff --git a/launcher/backend/include_public/DhfsStartOptions.hpp b/launcher/backend/include_public/DhfsStartOptions.hpp new file mode 100644 index 00000000..fa57fae1 --- /dev/null +++ b/launcher/backend/include_public/DhfsStartOptions.hpp @@ -0,0 +1,25 @@ +// +// Created by Stepan Usatiuk on 25.06.2025. +// + +#ifndef DHFSSTARTOPTIONS_HPP +#define DHFSSTARTOPTIONS_HPP + +#include +#include + +class DhfsStartOptions { +public: + std::string java_home; + std::string xmx; + std::string mount_path; + std::string data_path; + std::string jar_path; + std::string webui_path; + std::vector extra_options; + + std::vector getOptions(); +}; + + +#endif //DHFSSTARTOPTIONS_HPP diff --git a/launcher/backend/include_public/DhfsWxProcess.hpp b/launcher/backend/include_public/DhfsWxProcess.hpp new file mode 100644 index 00000000..df264534 --- /dev/null +++ b/launcher/backend/include_public/DhfsWxProcess.hpp @@ -0,0 +1,24 @@ +// +// Created by Stepan Usatiuk on 25.06.2025. +// + +#ifndef DHFSWXPROCESS_HPP +#define DHFSWXPROCESS_HPP +#include + + +class DhfsInstance; + +class DhfsWxProcess : public wxProcess { +public: + DhfsWxProcess(DhfsInstance& parent); + +protected: + void OnTerminate(int pid, int status) override; + +private: + DhfsInstance& _instance; +}; + + +#endif //DHFSWXPROCESS_HPP diff --git a/launcher/backend/src/DhfsInstance.cpp b/launcher/backend/src/DhfsInstance.cpp index 7409aa35..816ad60c 100644 --- a/launcher/backend/src/DhfsInstance.cpp +++ b/launcher/backend/src/DhfsInstance.cpp @@ -8,7 +8,6 @@ #include #include "Exception.h" -#include "LibjvmWrapper.hpp" DhfsInstance::DhfsInstance() { } @@ -17,10 +16,12 @@ DhfsInstance::~DhfsInstance() { } DhfsInstanceState DhfsInstance::state() { + std::lock_guard lock(_mutex); return _state; } -void DhfsInstance::start(const std::string& mount_path, const std::vector& extra_options) { +void DhfsInstance::start(DhfsStartOptions options) { + std::lock_guard lock(_mutex); switch (_state) { case DhfsInstanceState::RUNNING: return; @@ -31,23 +32,39 @@ void DhfsInstance::start(const std::string& mount_path, const std::vector options; - for (const auto& option: extra_options) { - options.emplace_back((char*) option.c_str(), nullptr); + std::vector args; + auto readyOptions = options.getOptions(); + for (const auto& option: readyOptions) { + args.push_back(const_cast(option.c_str())); } - std::string mount_option = "-Ddhfs.fuse.root="; - mount_option += mount_path; - options.emplace_back((char*) mount_option.c_str(), nullptr); - args.version = JNI_VERSION_21; - args.nOptions = options.size(); - args.options = options.data(); - args.ignoreUnrecognized = false; - LibjvmWrapper::instance().get_JNI_CreateJavaVM()(&_jvm, (void**) &_env, &args); + long ret = wxExecute(args.data(), wxEXEC_ASYNC | wxEXEC_HIDE_CONSOLE | wxEXEC_MAKE_GROUP_LEADER, process.get(), + nullptr); + if (ret == 0) { + _state = DhfsInstanceState::STOPPED; + throw Exception("Failed to start DHFS"); + } + + OnRead("Started! " + std::to_string(ret) + " PID: " + std::to_string(process->GetPid())); + + _readThread = std::thread([&]() { + auto stream = process->GetInputStream(); + while (!stream->Eof()) { + char buffer[1024]; + size_t bytesRead = stream->Read(buffer, sizeof(buffer) - 1).LastRead(); + if (bytesRead > 0) { + buffer[bytesRead] = '\0'; // Null-terminate the string + OnRead(std::string(buffer)); + } else if (bytesRead == 0) { + break; // EOF reached + } + } + OnRead("Stream end"); + }); } void DhfsInstance::stop() { + std::lock_guard lock(_mutex); switch (_state) { case DhfsInstanceState::RUNNING: break; @@ -57,12 +74,12 @@ void DhfsInstance::stop() { throw std::runtime_error("Unknown DhfsInstanceState"); } - if (_jvm == nullptr) - throw Exception("JVM not running"); - - JNIEnv* env; - _jvm->AttachCurrentThread((void**) &env, nullptr); - _jvm->DestroyJavaVM(); - _jvm = nullptr; _state = DhfsInstanceState::STOPPED; + + int err = wxProcess::Kill(process->GetPid(), wxSIGTERM, wxKILL_CHILDREN); + if (err != wxKILL_OK) { + throw Exception("Failed to stop DHFS: " + std::to_string(err)); + } + _readThread.join(); + OnRead("Stopped!"); } diff --git a/launcher/backend/src/DhfsStartOptions.cpp b/launcher/backend/src/DhfsStartOptions.cpp new file mode 100644 index 00000000..2b1b8d91 --- /dev/null +++ b/launcher/backend/src/DhfsStartOptions.cpp @@ -0,0 +1,31 @@ +// +// Created by Stepan Usatiuk on 25.06.2025. +// + +#include "DhfsStartOptions.hpp" + +std::vector DhfsStartOptions::getOptions() { + std::vector out; + out.emplace_back(java_home + "/bin/java"); + out.emplace_back("--enable-preview"); + out.emplace_back("-Xmx" + xmx); + out.emplace_back("-Ddhfs.objects.writeback.limit=16777216"); + out.emplace_back("-Ddhfs.objects.lru.limit=67108864"); + out.emplace_back("--add-exports"); + out.emplace_back("java.base/sun.nio.ch=ALL-UNNAMED"); + out.emplace_back("--add-exports"); + out.emplace_back("java.base/jdk.internal.access=ALL-UNNAMED"); + out.emplace_back("--add-opens=java.base/java.nio=ALL-UNNAMED"); + // out.emplace_back("-Dquarkus.http.host=0.0.0.0"); + // out.emplace_back("-Dquarkus.log.category.\"com.usatiuk\".level=INFO"); + // out.emplace_back("-Dquarkus.log.category.\"com.usatiuk.dhfs\".level=INFO"); + out.emplace_back("-Ddhfs.fuse.root=" + mount_path); + out.emplace_back("-Ddhfs.objects.persistence.root=" + data_path); + out.emplace_back("-Ddhfs.webui.root=" + webui_path); + for (auto option: extra_options) { + out.emplace_back(option); + } + out.emplace_back("-jar"); + out.emplace_back(jar_path); + return out; +} diff --git a/launcher/backend/src/DhfsWxProcess.cpp b/launcher/backend/src/DhfsWxProcess.cpp new file mode 100644 index 00000000..d4b92eb2 --- /dev/null +++ b/launcher/backend/src/DhfsWxProcess.cpp @@ -0,0 +1,14 @@ +// +// Created by Stepan Usatiuk on 25.06.2025. +// + +#include "DhfsWxProcess.hpp" + +#include "DhfsInstance.hpp" + +DhfsWxProcess::DhfsWxProcess(DhfsInstance& parent): wxProcess(wxPROCESS_REDIRECT), _instance(parent) { +} + +void DhfsWxProcess::OnTerminate(int pid, int status) { + _instance.stop(); +} diff --git a/launcher/gui/CMakeLists.txt b/launcher/gui/CMakeLists.txt index 3258ab5f..4461bea9 100644 --- a/launcher/gui/CMakeLists.txt +++ b/launcher/gui/CMakeLists.txt @@ -8,6 +8,8 @@ add_executable(launcher src/LauncherApp.cpp src/GLauncherApp.cpp src/LauncherAppMainFrame.cpp + src/DhfsGuiInstance.cpp + src/DhfsGuiInstance.hpp ) target_link_libraries(launcher ${wxWidgets_LIBRARIES}) diff --git a/launcher/gui/src/DhfsGuiInstance.cpp b/launcher/gui/src/DhfsGuiInstance.cpp new file mode 100644 index 00000000..0b97a9b8 --- /dev/null +++ b/launcher/gui/src/DhfsGuiInstance.cpp @@ -0,0 +1,23 @@ +// +// Created by Stepan Usatiuk on 25.06.2025. +// + +#include "DhfsGuiInstance.hpp" + +#include "LauncherAppMainFrame.h" + +DhfsGuiInstance::DhfsGuiInstance(LauncherAppMainFrame& parent): _parent(parent) { +} + +void DhfsGuiInstance::OnTerminate(int pid, int status) { + wxCommandEvent* event = new wxCommandEvent(SHUTDOWN_EVENT, _parent.GetId()); + event->SetEventObject(&_parent); + _parent.GetEventHandler()->QueueEvent(event); +} + +void DhfsGuiInstance::OnRead(std::string s) { + wxCommandEvent* event = new wxCommandEvent(NEW_LINE_OUTPUT_EVENT, _parent.GetId()); + event->SetEventObject(&_parent); + event->SetString(std::move(s)); + _parent.GetEventHandler()->QueueEvent(event); +} diff --git a/launcher/gui/src/DhfsGuiInstance.hpp b/launcher/gui/src/DhfsGuiInstance.hpp new file mode 100644 index 00000000..e2e385ce --- /dev/null +++ b/launcher/gui/src/DhfsGuiInstance.hpp @@ -0,0 +1,25 @@ +// +// Created by Stepan Usatiuk on 25.06.2025. +// + +#ifndef DHFSGUIINSTANCE_HPP +#define DHFSGUIINSTANCE_HPP +#include "DhfsInstance.hpp" + + +class LauncherAppMainFrame; + +class DhfsGuiInstance : public DhfsInstance { +public: + DhfsGuiInstance(LauncherAppMainFrame& parent); + + void OnTerminate(int pid, int status) override; + + void OnRead(std::string s) override; + +protected: + LauncherAppMainFrame& _parent; +}; + + +#endif //DHFSGUIINSTANCE_HPP diff --git a/launcher/gui/src/GLauncherApp.cpp b/launcher/gui/src/GLauncherApp.cpp index b0ed47b0..0f93e234 100644 --- a/launcher/gui/src/GLauncherApp.cpp +++ b/launcher/gui/src/GLauncherApp.cpp @@ -53,8 +53,18 @@ MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, co m_panel1->SetSizer( bSizer2 ); m_panel1->Layout(); bSizer2->Fit( m_panel1 ); - m_notebook1->AddPage( m_panel1, _("Info"), false ); + m_notebook1->AddPage( m_panel1, _("Info"), true ); m_panel3 = new wxPanel( m_notebook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxGridSizer* gSizer1; + gSizer1 = new wxGridSizer( 1, 1, 0, 0 ); + + m_logOutputTextCtrl = new wxTextCtrl( m_panel3, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY ); + gSizer1->Add( m_logOutputTextCtrl, 0, wxALL|wxEXPAND, 5 ); + + + m_panel3->SetSizer( gSizer1 ); + m_panel3->Layout(); + gSizer1->Fit( m_panel3 ); m_notebook1->AddPage( m_panel3, _("Logs"), false ); m_panel2 = new wxPanel( m_notebook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* bSizer5; @@ -120,7 +130,7 @@ MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, co m_panel4 = new wxPanel( m_notebook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_notebook1->AddPage( m_panel4, _("Advanced Settings"), false ); m_panel5 = new wxPanel( m_notebook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - m_notebook1->AddPage( m_panel5, _("a page"), true ); + m_notebook1->AddPage( m_panel5, _("a page"), false ); bSizer3->Add( m_notebook1, 1, wxALL|wxEXPAND, 5 ); diff --git a/launcher/gui/src/GLauncherApp.h b/launcher/gui/src/GLauncherApp.h index 0cbf68c5..4e958ddf 100644 --- a/launcher/gui/src/GLauncherApp.h +++ b/launcher/gui/src/GLauncherApp.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -45,6 +46,7 @@ class MainFrame : public wxFrame wxStaticText* m_statusText; wxButton* m_startStopButton; wxPanel* m_panel3; + wxTextCtrl* m_logOutputTextCtrl; wxPanel* m_panel2; wxButton* m_button2; wxDirPickerCtrl* m_javaHomeDirPicker; diff --git a/launcher/gui/src/LauncherAppMainFrame.cpp b/launcher/gui/src/LauncherAppMainFrame.cpp index c4b72ea7..ce790ce2 100644 --- a/launcher/gui/src/LauncherAppMainFrame.cpp +++ b/launcher/gui/src/LauncherAppMainFrame.cpp @@ -4,7 +4,9 @@ #include #include "Exception.h" -#include "LibjvmWrapper.hpp" + +wxDEFINE_EVENT(NEW_LINE_OUTPUT_EVENT, wxCommandEvent); +wxDEFINE_EVENT(SHUTDOWN_EVENT, wxCommandEvent); LauncherAppMainFrame::LauncherAppMainFrame(wxWindow* parent) : MainFrame(parent) { @@ -19,28 +21,57 @@ LauncherAppMainFrame::LauncherAppMainFrame(wxWindow* parent) m_webView = wxWebView::New(m_panel5, wxID_ANY); bSizer4->Add(m_webView, 0, wxALL | wxEXPAND); m_webView->LoadURL("http://localhost:8080"); + + Bind(NEW_LINE_OUTPUT_EVENT, &LauncherAppMainFrame::onNewLineOutput, this); + Bind(SHUTDOWN_EVENT, &LauncherAppMainFrame::onShutdown, this); + wxFont font = wxFont(wxSize(16, 16), + wxFontFamily::wxFONTFAMILY_TELETYPE, + wxFontStyle::wxFONTSTYLE_NORMAL, + wxFontWeight::wxFONTWEIGHT_NORMAL); + m_logOutputTextCtrl->SetFont(font); + updateState(); +} + +void LauncherAppMainFrame::updateState() { + switch (_dhfsInstance.state()) { + case DhfsInstanceState::RUNNING: + m_statusText->SetLabel("Running"); + m_startStopButton->SetLabel("Stop"); + m_statusBar1->SetStatusText("Running", 0); + break; + case DhfsInstanceState::STOPPED: { + // wxFileConfig::Get()->Read(kJavaHomeSettingsKey).ToStdString(); + m_statusText->SetLabel("Stopped"); + m_startStopButton->SetLabel("Start"); + m_statusBar1->SetStatusText("Stopped", 0); + break; + } + default: + throw Exception("Unhandled switch case"); + } } void LauncherAppMainFrame::OnStartStopButtonClick(wxCommandEvent& event) { switch (_dhfsInstance.state()) { case DhfsInstanceState::RUNNING: - m_statusText->SetLabel("Stopped"); - m_startStopButton->SetLabel("Start"); - m_statusBar1->SetStatusText("Stopped", 0); _dhfsInstance.stop(); break; - case DhfsInstanceState::STOPPED: - LibjvmWrapper::instance().setJavaHome(wxFileConfig::Get()->Read(kJavaHomeSettingsKey).ToStdString()); - m_statusText->SetLabel("Running"); - m_startStopButton->SetLabel("Stop"); - m_statusBar1->SetStatusText("Running", 0); - _dhfsInstance.start(wxFileConfig::Get()->Read(kMountPointSettingsKey).ToStdString(), { + case DhfsInstanceState::STOPPED: { + DhfsStartOptions options; + options.java_home = wxFileConfig::Get()->Read(kJavaHomeSettingsKey); + options.xmx = "512m"; // Default memory allocation, can be changed + options.mount_path = wxFileConfig::Get()->Read(kMountPointSettingsKey); + options.data_path = "/Users/stepus53/dhfs_test/launcher/data"; + options.jar_path = "/Users/stepus53/projects/dhfs/dhfs-parent/dhfs-fuse/target/quarkus-app/quarkus-run.jar"; + options.webui_path = "/Users/stepus53/projects/dhfs/webui/dist"; - }); + _dhfsInstance.start(options); break; + } default: throw Exception("Unhandled switch case"); } + updateState(); } void LauncherAppMainFrame::OnJavaHomeChanged(wxFileDirPickerEvent& event) { @@ -50,3 +81,12 @@ void LauncherAppMainFrame::OnJavaHomeChanged(wxFileDirPickerEvent& event) { void LauncherAppMainFrame::OnMountPathChanged(wxFileDirPickerEvent& event) { wxFileConfig::Get()->Write(kMountPointSettingsKey, event.GetPath()); } + +void LauncherAppMainFrame::onNewLineOutput(wxCommandEvent& event) { + m_logOutputTextCtrl->AppendText(event.GetString()); +} + +void LauncherAppMainFrame::onShutdown(wxCommandEvent& event) { + m_logOutputTextCtrl->AppendText("Shutdown"); + updateState(); +} diff --git a/launcher/gui/src/LauncherAppMainFrame.h b/launcher/gui/src/LauncherAppMainFrame.h index c363a8e3..ef0a7e10 100644 --- a/launcher/gui/src/LauncherAppMainFrame.h +++ b/launcher/gui/src/LauncherAppMainFrame.h @@ -10,11 +10,16 @@ Subclass of MainFrame, which is generated by wxFormBuilder. //// end generated include -#include "DhfsInstance.hpp" #include + +#include "DhfsGuiInstance.hpp" + static constexpr auto kJavaHomeSettingsKey = "DHFS/JavaHome"; static constexpr auto kMountPointSettingsKey = "DHFS/MountDir"; +wxDECLARE_EVENT(NEW_LINE_OUTPUT_EVENT, wxCommandEvent); +wxDECLARE_EVENT(SHUTDOWN_EVENT, wxCommandEvent); + /** Implementing MainFrame */ class LauncherAppMainFrame : public MainFrame { protected: @@ -25,6 +30,12 @@ protected: void OnMountPathChanged(wxFileDirPickerEvent& event) override; + void onNewLineOutput(wxCommandEvent& event); + + void onShutdown(wxCommandEvent& event); + + void updateState(); + public: /** Constructor */ LauncherAppMainFrame(wxWindow* parent); @@ -34,7 +45,7 @@ public: private: wxWebView* m_webView; - DhfsInstance _dhfsInstance; + DhfsGuiInstance _dhfsInstance{*this}; }; #endif // __LauncherAppMainFrame__ diff --git a/launcher/gui/src/launcher.fbp b/launcher/gui/src/launcher.fbp index e3d3b03f..72ccd39d 100644 --- a/launcher/gui/src/launcher.fbp +++ b/launcher/gui/src/launcher.fbp @@ -455,6 +455,80 @@ wxTAB_TRAVERSAL + + 1 + 0 + + gSizer1 + none + 1 + 0 + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_textCtrl2 + 1 + + + protected + 1 + + Resizable + 1 + + wxTE_MULTILINE|wxTE_READONLY + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + @@ -1055,23 +1129,6 @@ wxTAB_TRAVERSAL - - - bSizer4 - wxVERTICAL - none - - 5 - wxEXPAND - 1 - - - bSizer51 - wxHORIZONTAL - none - - - diff --git a/launcher/libjvm_wrapper/CMakeLists.txt b/launcher/libjvm_wrapper/CMakeLists.txt deleted file mode 100644 index 9540653c..00000000 --- a/launcher/libjvm_wrapper/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -add_library(libjvm_wrapper - src/LibjvmWrapper.cpp - include_public/LibjvmWrapper.hpp -) - -target_include_directories(libjvm_wrapper PRIVATE include) -target_include_directories(libjvm_wrapper PUBLIC include_public) - -find_package(JNI REQUIRED) -target_include_directories(libjvm_wrapper PUBLIC ${JNI_INCLUDE_DIRS}) - -target_link_libraries(libjvm_wrapper PUBLIC utils) \ No newline at end of file diff --git a/launcher/libjvm_wrapper/include_public/LibjvmWrapper.hpp b/launcher/libjvm_wrapper/include_public/LibjvmWrapper.hpp deleted file mode 100644 index 5dca76cf..00000000 --- a/launcher/libjvm_wrapper/include_public/LibjvmWrapper.hpp +++ /dev/null @@ -1,34 +0,0 @@ -// -// Created by Stepan Usatiuk on 24.06.2025. -// - -#ifndef LIBJVMWRAPPER_HPP -#define LIBJVMWRAPPER_HPP - -#include -#include - -class LibjvmWrapper { -public: - static LibjvmWrapper& instance(); - - void setJavaHome(const std::string& javaHome); - - decltype(JNI_CreateJavaVM)* get_JNI_CreateJavaVM(); - -private: - void load(); - - void unload(); - - LibjvmWrapper(); - - ~LibjvmWrapper(); - - void* _lib_handle = nullptr; - decltype(JNI_CreateJavaVM)* WJNI_CreateJavaVM = nullptr; - std::string _java_home; -}; - - -#endif //LIBJVMWRAPPER_HPP diff --git a/launcher/libjvm_wrapper/src/LibjvmWrapper.cpp b/launcher/libjvm_wrapper/src/LibjvmWrapper.cpp deleted file mode 100644 index 775472bf..00000000 --- a/launcher/libjvm_wrapper/src/LibjvmWrapper.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// -// Created by Stepan Usatiuk on 24.06.2025. -// - -#include "LibjvmWrapper.hpp" -#include -#include - -#include "Exception.h" - -LibjvmWrapper& LibjvmWrapper::instance() { - static LibjvmWrapper instance; - return instance; -} - -LibjvmWrapper::LibjvmWrapper() { -} - -void LibjvmWrapper::load() { - if (_java_home == "") - throw Exception("Java home not set"); - if (_lib_handle != nullptr) - throw Exception("load() called when already loaded"); - - std::string javaHomeAppended; - javaHomeAppended = _java_home + "/lib/server/libjvm.so"; - - _lib_handle = dlopen(javaHomeAppended.c_str(), RTLD_NOW | RTLD_GLOBAL); - if (_lib_handle == nullptr) - throw Exception(dlerror()); - WJNI_CreateJavaVM = reinterpret_cast( - dlsym(_lib_handle, "JNI_CreateJavaVM")); - if (WJNI_CreateJavaVM == nullptr) - throw Exception(dlerror()); -} - -void LibjvmWrapper::unload() { - if (_lib_handle != nullptr) { - dlclose(_lib_handle); - _lib_handle = nullptr; - WJNI_CreateJavaVM = nullptr; - } -} - -decltype(JNI_CreateJavaVM)* LibjvmWrapper::get_JNI_CreateJavaVM() { - if (WJNI_CreateJavaVM == nullptr) { - load(); - } - return WJNI_CreateJavaVM; -} - -LibjvmWrapper::~LibjvmWrapper() { - unload(); -} - -void LibjvmWrapper::setJavaHome(const std::string& javaHome) { - unload(); - _java_home = javaHome; -} diff --git a/launcher/utils/src/Exception.cpp b/launcher/utils/src/Exception.cpp index 63f2f96e..4503ddb5 100644 --- a/launcher/utils/src/Exception.cpp +++ b/launcher/utils/src/Exception.cpp @@ -7,8 +7,6 @@ #include #include -#include - Exception::Exception(const std::string& text) : runtime_error(text + "\n" + getStacktrace()) { }