Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native Shared Library Unable To List Names of Annotated Class #8893

Open
codewithakamathb opened this issue May 8, 2024 · 9 comments
Open
Assignees

Comments

@codewithakamathb
Copy link

codewithakamathb commented May 8, 2024

Earlier we were using IKVM to convert Jar into a .Net library and getting used in both Windows .Net App as well as in Mac via Mono.
We tried to use the same functionality via now Graal using Native Shared Library.
Everything worked seamlessly. Now we encountered a situation where we are listing classes which are annotated via Reflection (using org.reflections.Reflections)
Strange is if I run native-image -jar example.jar followed example.exe it's able to list all annotated classes inside the package via Reflection.
If I try to consume via Native Shared Library having a method which gives annotated class names it's not able to provide a list of annotated classes.
Can someone help me with this. I have attached the jar as well as the .Net application which consumes Native Shared Library. (edited)

Reflection.zip

@codewithakamathb
Copy link
Author

Commands used
"C:\Program Files\GraalVM\graalvm-ce-java11-22.3.2\bin\java.exe" -agentlib:native-image-agent=config-output-dir=META-INF/native-image -jar desktop-reflection-jar-with-dependencies.jar

native-image -cp desktop-reflection-jar-with-dependencies.jar --shared --no-fallback --allow-incomplete-classpath -H:IncludeResources="..xml|..conf" "-H:Name=dinterfacepoc" -H:+ReportExceptionStackTraces -H:+ReportUnsupportedElementsAtRuntime -H:TraceClassInitialization=True -H:ConfigurationFileDirectories=META-INF/native-image

@codewithakamathb
Copy link
Author

codewithakamathb commented May 8, 2024

Invocation Code

#include <stdio.h>
#include <stdlib.h>
#ifndef _WIN64
#include <dlfcn.h>
#else
#include <windows.h>
#endif
#include "InterviewServiceInterop.h"
#include <dinterfacepoc.h>

using namespace System;
using namespace System::Runtime::InteropServices;

#pragma managed(push, off)

graal_isolate_t* isolateIS = NULL;
graal_isolatethread_t* threadIS = NULL;

void InvokeListAnnotatedClass()
{
if (threadIS == NULL) {
if (graal_create_isolate(NULL, &isolateIS, &threadIS) != 0) {
fprintf(stderr, "error on isolate creation or attach\n");
}
}

list_annotated_class(threadIS);
return;

}

#pragma managed(pop)

System::Void Interop::InterviewServiceInterop::ListAnnotatedClass()
{

try {
	

	InvokeListAnnotatedClass();

	
}
catch (...) {

}

}

@kassifar kassifar self-assigned this May 9, 2024
@kassifar
Copy link

kassifar commented May 9, 2024

Hello @codewithakamathb thank you for reporting the issue that you are facing. Can you please specify the version of GraalVM that you are using as well as your system specification. Thank you.

@kassifar
Copy link

kassifar commented May 9, 2024

Can you also push your reproducer on a public github repo so that we can take a look at it? Thanks.

@codewithakamathb
Copy link
Author

Can you also push your reproducer on a public github repo so that we can take a look at it? Thanks.

Please find git link.

https://github.com/codewithakamathb/graalvm/tree/main

Please follow read me. If you need any help let me know

@codewithakamathb
Copy link
Author

Hello @codewithakamathb thank you for reporting the issue that you are facing. Can you please specify the version of GraalVM that you are using as well as your system specification. Thank you.

graalvm-ce-java11-22.3.2

@codewithakamathb
Copy link
Author

@kassifar any support or hints?

@kassifar
Copy link

Hi @codewithakamathb, we noticed that you are using graalvm-ce-java11-22.3.2. We recommend that you switch to our latest version of GraalVM: GraalVM for JDK 22 Community 22.0.1. Let us know if you are still encountering the same issue when you switch to the aforementioned version. Thank you.

@codewithakamathb
Copy link
Author

No it doesnt work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants