Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

Migrate *-agent samples to Native Build Tools agent support #1247

Closed
sbrannen opened this issue Nov 10, 2021 · 9 comments
Closed

Migrate *-agent samples to Native Build Tools agent support #1247

sbrannen opened this issue Nov 10, 2021 · 9 comments
Assignees
Labels
type: task A general task
Milestone

Comments

@sbrannen
Copy link
Contributor

The commandlinerunner-agent sample currently does not work.

At this point we should remove the following...

https://github.com/spring-projects-experimental/spring-native/blob/77be942e39c6c441beb65293d94e9e80de7ccd69/samples/commandlinerunner-agent/pom.xml#L47-L63

and

https://github.com/spring-projects-experimental/spring-native/blob/77be942e39c6c441beb65293d94e9e80de7ccd69/samples/commandlinerunner-agent/pom.xml#L80

... and switch to using the built-in support for running with the GraalVM agent using Native Build Tools.

@sbrannen sbrannen self-assigned this Nov 10, 2021
@sbrannen sbrannen added this to the 0.11.0-RC1 milestone Nov 10, 2021
@sbrannen sbrannen added the type: task A general task label Nov 10, 2021
@sbrannen sbrannen added the status: blocked An issue that's blocked on an external project change or another issue label Nov 11, 2021
@sbrannen
Copy link
Contributor Author

sbrannen added a commit that referenced this issue Nov 11, 2021
Prior to this commit, the commandlinerunner-agent sample application
was failing due to improper support for using the GraalVM native image
agent.

This commit performs a migration to the Native Build Tools (NBT)
support for running with the agent in Maven.

However, this is only a partial migration since NBT currently does not
provide a way to configure Access Filters for the agent. Consequently,
the commandlinerunner-agent sample application still fails, and gh-1247
is effectively blocked until the following NBT issue is resolved.

graalvm/native-build-tools#162

See gh-1247
@sdeleuze sdeleuze modified the milestones: 0.11.0-RC1, 0.11.0 Nov 11, 2021
@sdeleuze
Copy link
Contributor

I am not sure to understand why native-agent mode configuration has been removed, could you please share more about that?

@sbrannen
Copy link
Contributor Author

I am not sure to understand why native-agent mode configuration has been removed, could you please share more about that?

Good catch!

That was an experiment that I forgot to undo before committing.

I'll add it back.

sbrannen added a commit that referenced this issue Nov 12, 2021
I accidentally removed the native-agent mode in commit 0d6cd88.

This commit adds it back.

See gh-1247
@sbrannen sbrannen changed the title Migrate commandlinerunner-agent to Native Build Tools agent support Migrate *-agent samples to Native Build Tools agent support Nov 30, 2021
@sdeleuze sdeleuze removed the status: blocked An issue that's blocked on an external project change or another issue label Nov 30, 2021
@sdeleuze sdeleuze self-assigned this Dec 1, 2021
@sdeleuze sdeleuze added the status: blocked An issue that's blocked on an external project change or another issue label Dec 1, 2021
@sdeleuze
Copy link
Contributor

sdeleuze commented Dec 1, 2021

So far it seems we are blocked by an issue on GraalVM 21.3.

When executing the agent on tests, it generates this kind of entry that make native tests fail:

[
  {
    "name":"org.springframework.boot.availability.ApplicationAvailabilityBean",
    "allDeclaredFields":true,
    "queryAllPublicMethods":true
  }
]

With this error:

java.lang.ClassCastException: sun.reflect.generics.tree.FieldTypeSignature[] cannot be cast to java.lang.reflect.Type[]
       sun.reflect.generics.reflectiveObjects.TypeVariableImpl.getBounds(TypeVariableImpl.java:87)
       com.sun.beans.TypeResolver.erase(TypeResolver.java:242)
       com.sun.beans.TypeResolver.erase(TypeResolver.java:274)
       java.beans.FeatureDescriptor.getParameterTypes(FeatureDescriptor.java:391)
       java.beans.MethodDescriptor.setMethod(MethodDescriptor.java:118)

This error happen when executing native test, native compilation of the app is fine.

Also when using queryAllPublicMethods instead of allPublicMethods, it works as expected:

[
  {
    "name":"org.springframework.boot.availability.ApplicationAvailabilityBean",
    "allDeclaredFields":true,
    "allPublicMethods":true
  }
]

We need to bring that to GraalVM team attention. I think that mean we need to move agent support to at least 0.11.1.

@sdeleuze sdeleuze modified the milestones: 0.11.0, 0.11.1 Dec 1, 2021
@sdeleuze
Copy link
Contributor

sdeleuze commented Dec 4, 2021

Will require NBT 0.9.9 due to graalvm/native-build-tools#179.

@sdeleuze sdeleuze modified the milestones: 0.11.1, 0.11.2 Dec 17, 2021
@sdeleuze sdeleuze modified the milestones: 0.11.2, 0.11.3 Jan 20, 2022
@sdeleuze sdeleuze removed the status: blocked An issue that's blocked on an external project change or another issue label Feb 15, 2022
@sdeleuze
Copy link
Contributor

Blocked by 2 additional issues with NBT 0.9.10, see sdeleuze@test-agent.

@sdeleuze sdeleuze removed this from the 0.11.3 milestone Feb 15, 2022
@sdeleuze sdeleuze added this to the 0.11.4 milestone Feb 15, 2022
@sdeleuze
Copy link
Contributor

I created graalvm/native-build-tools#207 and graalvm/native-build-tools#208 related issues.

@sdeleuze sdeleuze modified the milestones: 0.11.4, 0.12.0 Mar 31, 2022
@sdeleuze sdeleuze modified the milestones: 0.12.0, 0.12.1 May 17, 2022
@sdeleuze sdeleuze added the status: blocked An issue that's blocked on an external project change or another issue label Jun 10, 2022
@sdeleuze
Copy link
Contributor

Depends on #1638.

@sdeleuze
Copy link
Contributor

Works with NBT 0.9.12-SNAPSHOT, mvn -Pnative -DskipNativeTests package and the following configuration:

<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-antrun-plugin</artifactId>
				<executions>
					<execution>
						<id>copy-agent-config</id>
						<phase>prepare-package</phase>
						<goals>
							<goal>run</goal>
						</goals>
						<configuration>
							<target>
								<mkdir dir="${project.build.directory}/native/agent-output/main"/>
								<copy todir="${project.build.directory}/native/agent-output/main">
									<fileset dir="${project.build.directory}/native/agent-output/test" />
								</copy>
							</target>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.springframework.experimental</groupId>
				<artifactId>spring-aot-maven-plugin</artifactId>
				<configuration>
					<mode>native-agent</mode>
					<removeSpelSupport>true</removeSpelSupport>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
			<plugin>
				<groupId>org.graalvm.buildtools</groupId>
				<artifactId>native-maven-plugin</artifactId>
				<extensions>true</extensions>
				<configuration>
					<agent>
						<enabled>true</enabled>
						<options name="test">
							<option>access-filter-file=${basedir}/access-filter.json</option>
						</options>
					</agent>
				</configuration>
			</plugin>
		</plugins>
	</build>

I will update the agent samples once NBT 0.9.12 has been released.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: task A general task
Development

No branches or pull requests

2 participants