I tracked down the conditions that cause this behaviour to this - the JDK that was being used to run the Maven build was of a different (higher) language level than what the target level was configured for the Maven Compiler plugin. For example - using JDK 8 but setting the target language level as 1.7.
When running the wsgen goal, all of the generated classes will use the JDK native language level, ignoring the Maven Compiler plugin settings. All other classes (that are not generated) will be compiled to the correct target level.
This is how the Maven Compiler Plugin was configured in my case...
After deploying a service to WebLogic that was being run with JDK 7, a whole bunch of java.lang.UnsupportedClassVersionError exceptions with Unsupported major.minor version 52.0 were being thrown. Whoops!
So how did I fix it?
I knew that I had to force the correct target language level across all class files. The wsgen goal documentation talked about the args parameter but was very scarce on information...
Specifies optional command-line options. Multiple elements can be specified, and each token must be placed in its own list.
That wasn't very helpful so I started to look for wsgen documentation. The most common relevant documentation I found was this:
pass this option to javac
Also not super helpful but it was a step in the right direction. I tried setting the target level but no matter what I tried, I either got errors or the values I passed in were ignored. Eventually I came across this page that finally had something that I could use...
Pass this option to Javac compiler. Note: use '=' instead of space as a delimiter between option name and its value.
This meant I had to use this string as the args parameter - "-J-source=1.7 -J-target=1.7". The configuration for the wsgen goal now became something like this...
After making this change, all of the compiled class files were for the correct target language level and no more exceptions were showing in WebLogic!
Of course I would not recommend hard coding the language level as I have in the examples above. In my actual pom.xml files this was all defined via variables.