From 5e4e4ca77fd698f27e8c18e0e9aba17ab59acab5 Mon Sep 17 00:00:00 2001 From: garyo Date: Fri, 29 May 2009 01:16:27 +0000 Subject: [PATCH] Fix for issue 2088: Java version 5 is same as 1.5 and 6 is same as 1.6. git-svn-id: http://scons.tigris.org/svn/scons/trunk@4212 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/engine/SCons/Tool/JavaCommon.py | 5 +++-- src/engine/SCons/Tool/JavaCommonTests.py | 27 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/engine/SCons/Tool/JavaCommon.py b/src/engine/SCons/Tool/JavaCommon.py index 6f513f1d..cc2c536f 100644 --- a/src/engine/SCons/Tool/JavaCommon.py +++ b/src/engine/SCons/Tool/JavaCommon.py @@ -65,7 +65,8 @@ if java_parsing: interfaces, and anonymous inner classes.""" def __init__(self, version=default_java_version): - if not version in ('1.1', '1.2', '1.3','1.4', '1.5', '1.6'): + if not version in ('1.1', '1.2', '1.3','1.4', '1.5', '1.6', + '5', '6'): msg = "Java version %s not supported" % version raise NotImplementedError, msg @@ -171,7 +172,7 @@ if java_parsing: if self.version in ('1.1', '1.2', '1.3', '1.4'): clazz = self.listClasses[0] self.listOutputs.append('%s$%d' % (clazz, self.nextAnon)) - elif self.version in ('1.5', '1.6'): + elif self.version in ('1.5', '1.6', '5', '6'): self.stackAnonClassBrackets.append(self.brackets) className = [] className.extend(self.listClasses) diff --git a/src/engine/SCons/Tool/JavaCommonTests.py b/src/engine/SCons/Tool/JavaCommonTests.py index 1d010879..92649b22 100644 --- a/src/engine/SCons/Tool/JavaCommonTests.py +++ b/src/engine/SCons/Tool/JavaCommonTests.py @@ -184,6 +184,23 @@ class Private { ] assert classes == expect, (expect, classes) + pkg_dir, classes = SCons.Tool.JavaCommon.parse_java(input, '5') + assert pkg_dir is None, pkg_dir + expect = [ + 'Empty', + 'Listener', + 'Test$Inner$1', + 'Test$Inner', + 'Test$Inner2', + 'Test$Inner3', + 'Test$1', + 'Test$1$1', + 'Test', + 'Private$1', + 'Private', + ] + assert classes == expect, (expect, classes) + def test_comments(self): @@ -386,6 +403,9 @@ public class Foo { pkg_dir, classes = SCons.Tool.JavaCommon.parse_java(input, '1.5') assert classes == ['Foo$1', 'Foo$1$1', 'Foo'], classes + pkg_dir, classes = SCons.Tool.JavaCommon.parse_java(input, '6') + assert classes == ['Foo$1', 'Foo$1$1', 'Foo'], classes + def test_nested_anonymous_inner_classes(self): @@ -433,6 +453,10 @@ public class NestedExample expect = [ 'NestedExample$1', 'NestedExample$1$1', 'NestedExample' ] assert expect == classes, (expect, classes) + pkg_dir, classes = SCons.Tool.JavaCommon.parse_java(input, '6') + expect = [ 'NestedExample$1', 'NestedExample$1$1', 'NestedExample' ] + assert expect == classes, (expect, classes) + def test_private_inner_class_instantiation(self): """Test anonymous inner class generated by private instantiation""" @@ -535,6 +559,9 @@ public class Foo pkg_dir, classes = SCons.Tool.JavaCommon.parse_java(input, '1.6') assert expect == classes, (expect, classes) + pkg_dir, classes = SCons.Tool.JavaCommon.parse_java(input, '6') + assert expect == classes, (expect, classes) + if __name__ == "__main__": -- 2.26.2