From f70b383d6292995c1e0521e7312e827022fe8fc9 Mon Sep 17 00:00:00 2001 From: mkersten Date: Thu, 13 Jan 2005 04:22:51 +0000 Subject: [PATCH] Updated to support running on JDK 1.5, and fixed related bug#82218 --- .../aspectj/tools/ajdoc/HtmlDecorator.java | 19 ++++++----- ajdoc/src/org/aspectj/tools/ajdoc/Util.java | 16 +++++++++ .../testdata/coverage/foo/ModelCoverage.java | 2 +- ajdoc/testdata/coverage/foo/NoMembers.java | 10 ++++++ .../aspectj/tools/ajdoc/CoverageTestCase.java | 34 ++++++++++--------- .../aspectj/tools/ajdoc/JDKVersionTest.java | 23 +++++++++++++ 6 files changed, 78 insertions(+), 26 deletions(-) create mode 100644 ajdoc/src/org/aspectj/tools/ajdoc/Util.java create mode 100644 ajdoc/testdata/coverage/foo/NoMembers.java create mode 100644 ajdoc/testsrc/org/aspectj/tools/ajdoc/JDKVersionTest.java diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java b/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java index f189b6c61..43d7b1851 100644 --- a/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java +++ b/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java @@ -401,11 +401,12 @@ class HtmlDecorator { String MARKER_2 = ""; int index1 = fbs.indexOf(MARKER_1, index); int index2 = fbs.indexOf(MARKER_2, index); - if (index1 < index2) { + if (index1 < index2 && index1 != -1) { return index1; - } - else { + } else if (index2 != -1){ return index2; + } else { + return index; } } @@ -416,15 +417,15 @@ class HtmlDecorator { String MARKER_3 = ""; int index1 = fbs.indexOf(MARKER_1, index); int index2 = fbs.indexOf(MARKER_2, index); - int index3 = fbs.indexOf(MARKER_3, index); - if (index1 < index2 && index1 < index3) { + int index3 = fbs.indexOf(MARKER_3, index); + if (index1 != -1 && index1 < index2 && index1 < index3) { return index1; - } - else if (index2 < index1 && index2 < index3) { + } else if (index2 != -1 && index2 < index1 && index2 < index3) { return index2; - } - else { + } else if (index3 != -1) { return index3; + } else { + return index; } } diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/Util.java b/ajdoc/src/org/aspectj/tools/ajdoc/Util.java new file mode 100644 index 000000000..e3c53f301 --- /dev/null +++ b/ajdoc/src/org/aspectj/tools/ajdoc/Util.java @@ -0,0 +1,16 @@ +/* + * Created on Jan 12, 2005 + */ +package org.aspectj.tools.ajdoc; + +/** + * @author Mik Kersten + */ +public class Util { + + public static boolean isExecutingOnJava5() { + String version = System.getProperty("java.class.version","44.0"); + return version.equals("49.0"); + } + +} diff --git a/ajdoc/testdata/coverage/foo/ModelCoverage.java b/ajdoc/testdata/coverage/foo/ModelCoverage.java index 5c14055c6..b05d7bc72 100644 --- a/ajdoc/testdata/coverage/foo/ModelCoverage.java +++ b/ajdoc/testdata/coverage/foo/ModelCoverage.java @@ -119,7 +119,7 @@ aspect DeclareCoverage { declare warning: call(* Point.setX(..)): "Illegal call."; declare parents: Point extends java.io.Serializable; - declare parents: Point+ implements java.util.Observable; +// declare parents: Point+ implements java.util.Observable; declare parents: Point && Line implements java.util.Observable; declare soft: SizeException : call(* Point.getX()); declare precedence: AdviceCoverage, InterTypeDecCoverage, *; diff --git a/ajdoc/testdata/coverage/foo/NoMembers.java b/ajdoc/testdata/coverage/foo/NoMembers.java new file mode 100644 index 000000000..d8dfcb3ce --- /dev/null +++ b/ajdoc/testdata/coverage/foo/NoMembers.java @@ -0,0 +1,10 @@ +/* + * Created on Jan 12, 2005 + */ + +/** + * @author Mik Kersten + */ +public class NoMembers { + +} diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java index 25182eaf7..34f22a03d 100644 --- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java +++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java @@ -33,7 +33,8 @@ public class CoverageTestCase extends TestCase { File file7 = new File("testdata/coverage/fluffy/bunny/rocks/Rocks.java"); File file8 = new File("testdata/coverage/fluffy/bunny/rocks/UseThisAspectForLinkCheckToo.java"); File file9 = new File("testdata/coverage/foo/PkgVisibleClass.java"); - + File file10 = new File("testdata/coverage/foo/NoMembers.java"); + File outdir = new File("testdata/coverage/doc"); public void testOptions() { @@ -54,6 +55,20 @@ public class CoverageTestCase extends TestCase { assertTrue(true); } + public void testCoveragePublicMode() { + outdir.delete(); + String[] args = { + "-public", + "-source", + "1.4", + "-d", + outdir.getAbsolutePath(), + file3.getAbsolutePath(), + file9.getAbsolutePath() + }; + org.aspectj.tools.ajdoc.Main.main(args); + } + public void testCoverage() { outdir.delete(); String[] args = { @@ -73,21 +88,8 @@ public class CoverageTestCase extends TestCase { file6.getAbsolutePath(), file7.getAbsolutePath(), file8.getAbsolutePath(), - file9.getAbsolutePath() - }; - org.aspectj.tools.ajdoc.Main.main(args); - } - - public void testCoveragePublicMode() { - outdir.delete(); - String[] args = { - "-public", - "-source", - "1.4", - "-d", - outdir.getAbsolutePath(), - file3.getAbsolutePath(), - file9.getAbsolutePath() + file9.getAbsolutePath(), + file10.getAbsolutePath() }; org.aspectj.tools.ajdoc.Main.main(args); } diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/JDKVersionTest.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/JDKVersionTest.java new file mode 100644 index 000000000..9e8b06b5f --- /dev/null +++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/JDKVersionTest.java @@ -0,0 +1,23 @@ +/* + * Created on Jan 12, 2005 + */ +package org.aspectj.tools.ajdoc; + +import junit.framework.TestCase; + +/** + * @author Mik Kersten + */ +public class JDKVersionTest extends TestCase { + +// public void testIsUsing1point4() { +// String v = System.getProperty("java.class.version","44.0"); +// assertTrue(("49.0".compareTo(v) > 0) && ("48.0".compareTo(v) <= 0)); +// assertFalse(Util.isExecutingOnJava5()); +// } + + public void testIsUsing1point5() { + assertTrue(Util.isExecutingOnJava5()); + } + +} -- 2.39.5