Using enum singleton coding pattern in a Domino Java Agent

  1. Open the Designer preferences and select the Compiler settings.

    Preferences

  2. Click on "Configure Project Specific Settings..."

  3. Select your project and click OK.

    select project

  4. Change the settings to 1.6 and default compliance settings.

    compliance settings

  5. Click OK. You should get a few prompts, select the default. Then open and save your agent again to recompile it.

Using your code I did this and ran it without error.

In the end I found changing the NOTES.INI setting JavaCompilerTarget from...

JavaCompilerTarget=CurrentJavaVersion

...to...

JavaCompilerTarget=1.6

and recreating the agent from scratch fixed the problem.

For Java agents it looks like there are two fields on the agent doc which control source and target Java versions.

These are $JavaCompilerSource and $JavaCompilerTarget.

They are set when a Java agent is created. The value of these fields depends on the value of the NOTES.INI JavaCompilerTarget entry when the agent was created. Changing the NOTES.INI entry after the agent is created and editing or recompiling the agent has no effect.

If I create a Java agent when the NOTES.INI variable "JavaCompilerTarget" is set to "CurrentJavaVersion", the field "$JavaCompilerTarget" gets set to the value "CurrentJ" and the field "$JavaCompilerSource" gets set to the value "1.6".

If I create a Java agent when the NOTES.INI variable "JavaCompilerTarget" is set to "1.6" then the field "$JavaCompilerTarget" gets set to the value "1.6" and the field "$JavaCompilerSource" gets set to the value "1.6".

If this particular agent's "$JavaCompilerTarget" field has a value of "CurrentJ" then I get the exception.

Whereas if I recreate the same agent and its "$JavaCompilerTarget" field has a value of "1.6", I do not get the exception.

If I recreate this agent when the NOTES.INI variable is set to "1.5" then both the agent field values are set to "1.5" and the agent runs without any errors.

If I use ytria scanEZ to change the broken agent (the one that has the field $JavaCompilerTarget="CurrentJ") so that the value is "1.6" instead, and I then open and re-save the agent in designer, it no longer throws an exception. If I change the field value back to "CurrentJ" and re-save the agent it throws the exception again.

So it seems having a Java agent field $JavaCompilerTarget="CurrentJ" is not good and this happens when you have a NOTES.INI entry of JavaCompilerTarget=CurrentJavaVersion.

I have no idea why this changes the JVM behaviour but it does for me on 8.5.3 FP3.