Skip to content

Commit b6c7d36

Browse files
authored
Merge pull request #1531 from xael-fry/1526_deprecated-param
fix(command): remove deprecated use of -noverify jvm parameter (1526)
2 parents 11509ee + 772576c commit b6c7d36

File tree

5 files changed

+35
-24
lines changed

5 files changed

+35
-24
lines changed

framework/pym/play/application.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -291,15 +291,13 @@ def java_cmd(self, java_args, cp_args=None, className='play.server.Server', args
291291
java_args.append('-server')
292292

293293
if 'jvm_version' in self.play_env:
294-
javaVersion = self.play_env['jvm_version']
294+
java_version = self.play_env['jvm_version']
295295
else:
296-
javaVersion = getJavaVersion()
297-
print("~ using java version \"%s\"" % javaVersion)
298-
299-
if javaVersion.startswith("1.5") or javaVersion.startswith("1.6") or javaVersion.startswith("1.7") or javaVersion.startswith("1.8") or javaVersion.startswith("9") or javaVersion.startswith("10") :
300-
print("~ ERROR: java version prior to 11 are no longer supported: current version \"%s\" : please update" % javaVersion)
301-
302-
java_args.append('-noverify')
296+
java_version = get_java_version()
297+
print("~ using java version \"%s\"" % java_version)
298+
299+
if is_java_version_supported(java_version):
300+
print("~ ERROR: java version prior to %s are no longer supported: current version \"%s\" : please update" % (get_minimal_supported_java_version(), java_version))
303301

304302
java_policy = self.readConf('java.policy')
305303
if java_policy != '':

framework/pym/play/commands/eclipse.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,11 @@ def execute(**kargs):
3030
application_name = app.readConf('application.name')
3131
vm_arguments = app.readConf('jvm.memory')
3232

33-
javaVersion = getJavaVersion()
33+
javaVersion = get_java_version()
3434

3535
print("~ using java version \"%s\"" % javaVersion)
36-
if javaVersion.startswith("1.5") or javaVersion.startswith("1.6") or javaVersion.startswith("1.7"):
37-
print("~ ERROR: java version prior to 1.8 are no longer supported: current version \"%s\" : please update" % javaVersion)
38-
39-
vm_arguments = vm_arguments +' -noverify'
36+
if is_java_version_supported(javaVersion):
37+
print("~ ERROR: java version prior to %s are no longer supported: current version \"%s\" : please update" % (get_minimal_supported_java_version(), javaVersion))
4038

4139
if application_name:
4240
application_name = application_name.replace("/", " ")

framework/pym/play/commands/javadoc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def defineJavadocOptions(app, outdir, args):
7474
args.remove('--links')
7575
# Add link to JavaDoc of JAVA
7676

77-
javaVersion = getJavaVersion()
77+
javaVersion = get_java_version()
7878
print("~ using java version \"%s\"" % javaVersion)
7979
if javaVersion.startswith("1.5"):
8080
print("~ Java(TM) Platform, Platform Standard Edition 5.0")

framework/pym/play/utils.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def package_as_war(app, env, war_path, war_zip_path, war_exclusion_list = None):
188188
zip.close()
189189

190190
# Recursively delete all files/folders in root whose name equals to filename
191-
# We could pass a "ignore" parameter to copytree, but that's not supported in Python 2.5
191+
# We could pass an "ignore" parameter to copytree, but that's not supported in Python 2.5
192192

193193
def deleteFrom(root, filenames):
194194
for f in os.listdir(root):
@@ -250,15 +250,30 @@ def java_path():
250250
else:
251251
return os.path.normpath("%s/bin/java" % os.environ['JAVA_HOME'])
252252

253-
def getJavaVersion():
253+
def get_java_version():
254254
sp = subprocess.Popen([java_path(), "-version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
255-
javaVersion = sp.communicate()
256-
javaVersion = str(javaVersion)
255+
java_version = sp.communicate()
256+
java_version = str(java_version)
257257

258-
result = re.search('version "([a-zA-Z0-9\.\-_]{1,})"', javaVersion)
258+
result = re.search('version "([a-zA-Z0-9\.\-_]{1,})"', java_version)
259259

260260
if result:
261261
return result.group(1)
262262
else:
263-
print("Unable to retrieve java version from " + javaVersion)
263+
print("Unable to retrieve java version from " + java_version)
264264
return ""
265+
266+
def get_minimal_supported_java_version():
267+
return 11
268+
269+
def is_java_version_supported(java_version):
270+
try:
271+
if java_version.startswith("1."):
272+
num = int(java_version.split('.')[-1])
273+
elif java_version.count('.') >= 1:
274+
num = int(java_version.split('.')[0])
275+
else:
276+
num = int(java_version)
277+
return not (num < get_minimal_supported_java_version())
278+
except ValueError:
279+
return True

samples-and-tests/i-am-a-developer/test_jvm_version_flag.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def setUp(self):
2323
'jpda.port': 8000
2424
}
2525

26-
@mock.patch('play.application.getJavaVersion', return_value='')
26+
@mock.patch('play.application.get_java_version', return_value='')
2727
def testWithFlag(self, mock):
2828
play_env = self.common.copy()
2929
# pass the jvm_version flag in
@@ -32,17 +32,17 @@ def testWithFlag(self, mock):
3232
play_app = PlayApplication('fake', play_env, True)
3333
play_app.java_cmd([])
3434

35-
step('Assert getJavaVersion was not called')
35+
step('Assert get_java_version was not called')
3636
mock.assert_(not mock.called)
3737

38-
@mock.patch('play.application.getJavaVersion', return_value='')
38+
@mock.patch('play.application.get_java_version', return_value='')
3939
def testWithoutFlag(self, mock):
4040
play_env = self.common.copy()
4141

4242
play_app = PlayApplication('fake', play_env, True)
4343
play_app.java_cmd([])
4444

45-
step('Assert getJavaVersion was called once')
45+
step('Assert get_java_version was called once')
4646
mock.assert_(mock.called)
4747

4848

0 commit comments

Comments
 (0)