From 573741c8081c6b6b45921cafaae39f37eede2302 Mon Sep 17 00:00:00 2001 From: aclement Date: Wed, 28 Jul 2004 14:43:40 +0000 Subject: [PATCH] Fix for 64331 java.lang.NullPointerException in WeaverMessageHandler class --- .../compiler/WeaverMessageHandler.java | 20 ++++++++++++------ tests/ajcTests.xml | 7 ++++++ tests/bugs/abstractITDs/A.java | 2 ++ tests/bugs/abstractITDs/B.aj | 3 +++ tests/bugs/abstractITDs/B.jar | Bin 0 -> 1396 bytes tests/bugs/abstractITDs/C.java | 2 ++ tests/bugs/abstractITDs/buildBJar.bat | 1 + .../src/org/aspectj/weaver/ResolvedTypeX.java | 9 +++++++- 8 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 tests/bugs/abstractITDs/A.java create mode 100644 tests/bugs/abstractITDs/B.aj create mode 100644 tests/bugs/abstractITDs/B.jar create mode 100644 tests/bugs/abstractITDs/C.java create mode 100644 tests/bugs/abstractITDs/buildBJar.bat diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/WeaverMessageHandler.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/WeaverMessageHandler.java index 71017a6c3..a379fccb6 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/WeaverMessageHandler.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/WeaverMessageHandler.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.aspectj.ajdt.internal.compiler; +import java.util.ArrayList; import java.util.List; import org.aspectj.ajdt.internal.compiler.lookup.EclipseSourceLocation; @@ -164,12 +165,13 @@ public class WeaverMessageHandler implements IMessageHandler { private IProblem[] buildSeeAlsoProblems(List sourceLocations, CompilationResult problemSource, boolean usedBinarySourceFileName) { - int probLength = sourceLocations.size(); - if (usedBinarySourceFileName) probLength++; - IProblem[] ret = new IProblem[probLength]; + List ret = new ArrayList(); + for (int i = 0; i < sourceLocations.size(); i++) { ISourceLocation loc = (ISourceLocation) sourceLocations.get(i); - ret[i] = new DefaultProblem(loc.getSourceFile().getPath().toCharArray(), + if (loc != null ) { + DefaultProblem dp = + new DefaultProblem( loc.getSourceFile().getPath().toCharArray(), "see also", 0, new String[] {}, @@ -177,13 +179,19 @@ public class WeaverMessageHandler implements IMessageHandler { getStartPos(loc,null), getEndPos(loc,null), loc.getLine()); + ret.add(dp); + } else { + throw new RuntimeException("Internal Compiler Error: Unexpected null source location passed as 'see also' location."); + } } if (usedBinarySourceFileName) { - ret[ret.length -1] = new DefaultProblem(problemSource.fileName,"see also",0,new String[] {}, + DefaultProblem dp = new DefaultProblem(problemSource.fileName,"see also",0,new String[] {}, ProblemSeverities.Ignore,0, 0,0); + ret.add(dp); } - return ret; + IProblem[] retValue = (IProblem[])ret.toArray(new IProblem[]{}); + return retValue; } } diff --git a/tests/ajcTests.xml b/tests/ajcTests.xml index 85c36164b..f76405da3 100644 --- a/tests/ajcTests.xml +++ b/tests/ajcTests.xml @@ -7795,4 +7795,11 @@ + + + + + + diff --git a/tests/bugs/abstractITDs/A.java b/tests/bugs/abstractITDs/A.java new file mode 100644 index 000000000..5d9e777af --- /dev/null +++ b/tests/bugs/abstractITDs/A.java @@ -0,0 +1,2 @@ +public abstract class A { +} diff --git a/tests/bugs/abstractITDs/B.aj b/tests/bugs/abstractITDs/B.aj new file mode 100644 index 000000000..54af3233e --- /dev/null +++ b/tests/bugs/abstractITDs/B.aj @@ -0,0 +1,3 @@ +public aspect B { + abstract public void A.foo(); +} \ No newline at end of file diff --git a/tests/bugs/abstractITDs/B.jar b/tests/bugs/abstractITDs/B.jar new file mode 100644 index 0000000000000000000000000000000000000000..b0fcaad10b33b113e2a2ce658e5670a83d59682e GIT binary patch literal 1396 zcmWIWW@Zs#-~hs+sy_w{NI-;vg~8V~#8KDN&rRRg(a+P(H8@1i*X`da28PeRXHNTg z>*`(P_14uocjo-&AcHH$51tn3dHL#i`d%zuwI!%PN6*7o?_*HGx%0Xw&UorRdiv-o z6GMPEJIAIg;a!$Mi_C#I0H^irKv_q<}liQpMQVlbx87Bpu{TJC%rYe za`mp#x_HxFWtvG&MX6Sg*KvOQd9+I*@6BYnPF?rJr;Y~~Le%rdwG|rRjWp8BlwrK@fzqf|WHvg9YWOtbL-P6Y% zyqC`rOYgXGBb?=vr9|+%qO>Hr*t(?u$|u-+9w(ltIWgy>=b;uB{WInN-)THxQ9rX; z!tQC39B(3{p$hkJ_WO|qkAE?P!sws>uB!LI5O8566h=;vFscoS_7`>(`Pa7Xi<791 zxZ_hb*Qf(wuXH!MTo&`_V3oU-VBmYEMDkYdtGvzDPd|0nJakkLRPNmO@j-vkd7p6B z%R4-+pU<(p|MOf;dfEQ}KR$^%aGjTou;VypaN)sko4ZfKboYklayYX+OqO`WtDG0L zEaq|A=C>V8`MaAEclIWD(L=kN-ze9q-5QCpWy*tRuq=cH&h$C{%ysx8xc zmuY>U#MJr3ta*RJ`%CY9dAGzyUbr3TBG|cr-Fy+p0&|}*`@;$1mlX00zli&K=WM$l z-WnX{*cNfotfF|f^|DWU6W(uH)|V6^`aQYjMe5xW$z@i@ryRN|uqp5Tx*2)h-i!B% zoIhUt(e}1l!J-+bSM{amE}!-&uUjQ+2_MUSalfq6{Qj8Y_$g;*9aZIY-Sw<#hx>7r z5)t99LYc`+9N2elJucv(vQk9dlw%=#8&?Ui%O^6j&? z+qUkm%IKJ8lB?apu4sDo=aH$NQv<<_ZR=iJLGGwl~# z-|ulU&$=zbcISY3crpr+;0!#DPiMj4FIy`<(yp zzh