Skip to content

Commit 8c79617

Browse files
authored
Merge pull request #2 from M-Tsur:inject-java-9-flags
Inject java 9 flags to Takipi Agent
2 parents 7e006c4 + b939779 commit 8c79617

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

docs/framework-takipi_agent.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ The framework can be configured by modifying the [`config/takipi_agent.yml`][] f
3636
| `node_name_prefix` | Node name prefix, will be concatenated with `-` and instance index
3737
| `application_name` | Override the CloudFoundry default application name
3838

39+
### Remarks
40+
In case **Java 9+** is being used, 2 JVM flags will be added to the execution:
41+
| Name | Description
42+
| ---- | -----------
43+
| `-XX:-UseTypeSpeculation` | Disable type speculation optimization of the JVM which might not work properly in some situations where an agent is present.
44+
| `-Xshare:off` | Disable class sharing as it might affect the agent's bytecode manipulation work.
45+
46+
These two flags are needs as otherwise the agent or the JVM might not work properly together.
47+
3948
## Logs
4049

4150
Currently, you can get the Takipi agent logs using `cf files` command:

lib/java_buildpack/framework/takipi_agent.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ def release
3939
.add_agentpath(agent)
4040
.add_system_property('takipi.name', application_name)
4141

42+
update_java9
43+
4244
@droplet.environment_variables
4345
.add_environment_variable('LD_LIBRARY_PATH',
4446
"$LD_LIBRARY_PATH:#{qualify_path(lib, @droplet.root)}")
@@ -99,6 +101,14 @@ def node_name
99101
"#{@configuration['node_name_prefix']}-$CF_INSTANCE_INDEX"
100102
end
101103

104+
def update_java9
105+
return unless @droplet.java_home.java_9_or_later?
106+
107+
@droplet.java_opts
108+
.add_system_property('-Xshare:off')
109+
.add_system_property('-XX:-UseTypeSpeculation')
110+
end
111+
102112
end
103113

104114
end

0 commit comments

Comments
 (0)