Community
Participate
Working Groups
following error occured during compiling my project. here is exception from log. see java file below (i removed all methods except one, so there are a lot of comiplation errors, but the problem occurs even if all is okay there) !ENTRY org.eclipse.core.resources 2 75 Jul 25, 2003 15:12:34.100 !MESSAGE Errors during build. !SUBENTRY 1 org.eclipse.jdt.core 2 75 Jul 25, 2003 15:12:34.100 !MESSAGE org.eclipse.jdt.internal.compiler.lookup.ArrayBinding !STACK 0 java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.lookup.ArrayBinding at org.eclipse.jdt.internal.compiler.ast.MessageSend.resolveType (MessageSend.java:273) at org.eclipse.jdt.internal.compiler.ast.Expression.resolveTypeExpecting (Expression.java:447) at org.eclipse.jdt.internal.compiler.ast.IfStatement.resolve (IfStatement.java:258) at org.eclipse.jdt.internal.compiler.ast.Block.resolve(Block.java:108) at org.eclipse.jdt.internal.compiler.ast.ForStatement.resolve (ForStatement.java:321) at org.eclipse.jdt.internal.compiler.ast.Block.resolve(Block.java:108) at org.eclipse.jdt.internal.compiler.ast.IfStatement.resolve (IfStatement.java:261) at org.eclipse.jdt.internal.compiler.ast.Block.resolve(Block.java:108) at org.eclipse.jdt.internal.compiler.ast.IfStatement.resolve (IfStatement.java:261) at org.eclipse.jdt.internal.compiler.ast.Block.resolve(Block.java:108) at org.eclipse.jdt.internal.compiler.ast.IfStatement.resolve (IfStatement.java:261) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatement s(AbstractMethodDeclaration.java:361) at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements (MethodDeclaration.java:140) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve (AbstractMethodDeclaration.java:351) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve (TypeDeclaration.java:846) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve (TypeDeclaration.java:887) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve (CompilationUnitDeclaration.java:270) at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:533) at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:328) at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile (AbstractImageBuilder.java:198) at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile (AbstractImageBuilder.java:171) at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.build (BatchImageBuilder.java:51) package com.bc.pt.graphing; import java.awt.*; import java.io.*; import java.util.*; import com.bc.expr.*; /** * This class is for drawing one graph */ public class SimpleGraph { /** * Get orientation of graph. If independent variable is x then <code>orient=0</code>, if independent variable is y then <code>orient=1</code> */ protected int orient; // graph orientation private final static int HORZ = 0; private final static int VERT = 1; private int type; // graph type (equality, inequality) private final static int NONE = -1; private final static int EQUAL = 0; private final static int LESS = 1; private final static int MORE = 2; private final static int DOTS = 3; private final static int IMPLICIT = 4; private final static int PARAM = 5; private boolean implicit = false; private ExprChunk expr = null; private ExprChunk exprX = null; // expression to graph private ExprChunk exprY = null; // expression to graph private Dot[] dots = null; private static final ExprChunk t = new ExprChunk (ExprChunk.VARIABLE,"t"); private ExprContext varsX; // variables to use in expression (for exprX) private ExprContext varsY; // variables to use in expression (for exprY) private String depVarX; // name of dependant variable (for exprX) private String depVarY; // name of dependant variable (for exprY) private String depVar1,depVar2; private double minArg = Double.NaN; private double maxArg = Double.NaN; private double[] singularPoints=new double[0]; private boolean[] drawedSingular=new boolean[0]; private String minArgDot = "none"; private String maxArgDot = "none"; private int xSteps = 100; private int ySteps = 100; private int tSteps = 100; private boolean previousIn=true; protected Style style = new Style(); //style for drawing lines protected boolean isUpdated = false; // true is graph is changed since previous paint private String interpolator = null; private int dotRadius = 4; // to change radius for dots /** * Coordinate plane where this graph is drawn */ protected Coordinates cp; // coordinate plane /** * Color for filling */ protected Color fillColor = Color.cyan; /** * Filling pattern */ protected int[] fillPattern; /** * Is empty place in filling and in drawing line transparent */ protected boolean isTransparent = true; /** * Indicates whether to draw dots or not */ private String drawDots=null; private static Hashtable fillPatterns = new Hashtable(); private double[][] grid; //values of a function on a grid private double yMin, yMax, xMin, xMax; protected Color bgColor = Color.white; private static int[] pow = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; /** * Used to paint graphs and other over-axes elements */ public synchronized void paint(Graphics g) { //System.out.println("paint: "+type+" "+this.hashCode()); if (type == NONE) return; double minx = orient == HORZ ? Math.min(cp.getMinX(),cp.getMaxX ()) : Math.min(cp.getMinY(),cp.getMaxY()); double maxx = orient == HORZ ? Math.max(cp.getMinX(),cp.getMaxX ()) : Math.max(cp.getMinY(),cp.getMaxY()); double miny = orient == HORZ ? Math.min(cp.getMinY(),cp.getMaxY ()) : Math.min(cp.getMinX(),cp.getMaxX()); double maxy = orient == HORZ ? Math.max(cp.getMinY(),cp.getMaxY ()) : Math.max(cp.getMinX(),cp.getMaxX()); Color oldColor = g.getColor(); double[] curveParam=new double[]{0}; if (type == DOTS && dots!=null && dots.length>0){ if (interpolator == null){ Point p0 = null, p1 = null; for(int i=0;i<dots.length;i++) { p0 = point(dots[i].x,dots[i].y); p0.y++; if (p0 != null && p1 != null) style.drawLine(g,p0.x,p0.y,p1.x,p1.y,curveParam); p1 = p0; } }else{ if (interpolator.equals("func")) { Interpolator interp = new SplineInterpolator(); for(int i=0;i<dots.length;i++) { interp.addPoint(dots[i]); } g.setColor(style.lineColor); Point p0 = null, p1 = null; double t0 = dots[0].x, t1 = dots [dots.length-1].x; double kt = (t1-t0)/(double)tSteps; for (int n=0;n<=tSteps;n++) { p0 = p1; double t = t0 + kt*n; p1 = point(t,interp.getValue (t)); if (p0!=null) style.drawLine (g,p0.x,p0.y,p1.x,p1.y,curveParam); } } else {//parametric Interpolator interpx = interpolator.equals("line") ? (Interpolator)new LinearInterpolator() : new SplineInterpolator(); Interpolator interpy = interpolator.equals("line") ? (Interpolator)new LinearInterpolator() : new SplineInterpolator(); double t=0.0; for(int i=0;i<dots.length;i++) { interpx.addPoint(new Dot(t,dots [i].x)); interpy.addPoint(new Dot(t,dots [i].y)); t+=1.0; } g.setColor(style.lineColor); Point p0 = null, p1 = null; for (t=0;t<(double)dots.length-1.0;t+= (double)dots.length/(double)tSteps) { p0 = p1; p1 = point(interpx.getValue (t),interpy.getValue(t)); if (p0!=null) style.drawLine (g,p0.x,p0.y,p1.x,p1.y,curveParam); } } } if (interpolator == null || drawDots!=null){ if (drawDots == null || drawDots.toLowerCase ().equals("always")){ Point p0; for(int i=0;i<dots.length;i++) { p0 = point(dots[i].x,dots[i].y); p0.y++; if (fillPattern.equals((int[]) fillPatterns.get("EMPTY"))) { g.setColor(bgColor); g.fillOval(p0.x - dotRadius,p0.y-dotRadius,2*dotRadius,2*dotRadius); g.setColor (style.lineColor); g.drawOval(p0.x - dotRadius,p0.y-dotRadius,2*dotRadius,2*dotRadius); } else{ g.setColor (style.lineColor); g.fillOval(p0.x - dotRadius,p0.y-dotRadius,2*dotRadius,2*dotRadius); g.setColor(oldColor); } } } } } else if (implicit) { g.setColor(style.lineColor); drawImplicitCurve(g); g.setColor(oldColor); } else { g.setColor(style.lineColor); Point p0 = null, p1 = null; Point dot0 = null, dot1=null; boolean skipped = false; double p0d[] = null, p1d[] = null; double prevFY=0, prevFX=0, prevDFY=0, dfy = 0; double t0 = getMinArg(), t1 = getMaxArg(); double derivXmin = Double.NaN, derivXmax = Double.NaN; double[] arrowHadlePointsXmin = null, arrowHadlePointsXmax = null; //x0=startParam,x1=endParam double fx=0,fy=0; double kt = (t1-t0)/(double)tSteps; previousIn=true; for (int n=0;n<=tSteps;n++) { p0=p1; p0d = p1d; prevFY = fy; prevFX = fx; prevDFY = dfy; double t = t0 + kt*n; double distance = kt; int nearestSP = -1; for (int sp = 0; sp < singularPoints.length; sp++){ if (!drawedSingular[sp] && Math.abs (singularPoints[sp]-(t-kt))<distance){ distance = Math.abs (singularPoints[sp]-(t-kt)); nearestSP = sp; } } if (nearestSP!=-1){ t = singularPoints[nearestSP]; drawedSingular[nearestSP]=true; } if (type == PARAM) { if (depVarY != null && depVarX != null) { varsY.setVariable(depVarY,new Double(t)); varsX.setVariable(depVarX,new Double(t)); fy = getYValue(t); fx = getXValue(t); p1d = (Double.isNaN(fx) || Double.isInfinite(fx) || Double.isNaN(fy) || Double.isInfinite(fy)) ? null : orient == HORZ ? pointD(fx,fy) : pointD(fy,fx); if(n==1 || n == tSteps){ double[] pPrev = Double.isNaN(prevFY) || Double.isInfinite(prevFY) ? null : orient == HORZ ? pointD(prevFX,prevFY) : pointD(prevFY,prevFX); double[] pCur = Double.isNaN(fy) || Double.isInfinite(fy) ? null : orient == HORZ ? pointD (fx,fy) : pointD(fy,fx); if (pPrev!=null && pCur! =null){ if(n==1){ arrowHadlePointsXmin = new double[] {pPrev[0], pPrev[1], pCur[0], pCur [1]}; derivXmin = (-pCur[1]+pPrev[1])/(pCur[0]-pPrev[0]); } else{ arrowHadlePointsXmax = new double[] {pCur[0], pCur[1], pPrev[0], pPrev [1]}; derivXmax = (-pCur[1]+pPrev[1])/(pCur[0]-pPrev[0]); } } } } } else if (depVarY != null) { varsY.setVariable(depVarY,new Double (t)); fy = getValue(t); fx = t; //define derivative at the points Xmin and Xmax p1d = Double.isNaN(fy) || Double.isInfinite(fy) ? null : orient == HORZ ? pointD(fx,fy) : pointD(fy,fx); if(n==1 || n == tSteps){ double[] pPrev = Double.isNaN (prevFY) || Double.isInfinite(prevFY) ? null : orient == HORZ ? pointD (prevFX,prevFY) : pointD(prevFY,prevFX); double[] pCur = Double.isNaN (fy) || Double.isInfinite(fy) ? null : orient == HORZ ? pointD(fx,fy) : pointD (fy,fx); if (pPrev != null && pCur != null){ if(n==1){ arrowHadlePointsXmin = new double[] {pPrev[0], pPrev[1], pCur[0], pCur [1]}; derivXmin = (- pCur[1]+pPrev[1])/(pCur[0]-pPrev[0]); } else{ arrowHadlePointsXmax = new double[] {pCur[0], pCur[1], pPrev[0], pPrev [1]}; derivXmax = (- pCur[1]+pPrev[1])/(pCur[0]-pPrev[0]); } } } } p1 = (p1d == null) ? null : new Point( (int)p1d [0], (int)p1d[1] ); boolean currentIn = fy > miny && fy < maxy && fx > minx && fx < maxx; dfy = fy - prevFY; if (p0 != null && p1 != null) { if (n==1){ dot0 = new Point(p0); } if (n==tSteps){ dot1 = new Point(p1); } if (currentIn || previousIn || skipped){ boolean skip = false; if (p0 != null && n < tSteps && singularPoints.length == 0) { if (n > 1 && currentIn && Math.abs( dfy - prevDFY ) < 0.00000001 && type != PARAM) { // this line segment is a continuation of the previous segment skip = true; p1 = p0; p1d = p0d; currentIn = previousIn; } } skip = skip || (Math.abs(p0d[0]- p1d[0])>1e4) || (Math.abs(p0d[1]-p1d[1])>1e4); //System.out.print( skip ? "- " : "d" ); if (! skip ) style.drawLineD(g,p0d [0],p0d[1],p1d[0],p1d[1],curveParam,true); skipped = skip; }else style.flush(g); } previousIn = currentIn; if (nearestSP!=-1) { n--; } } if (dot0 != null){ style.flush(g); if (minArgDot.equals("opened") || minArgDot.equals("open")) { Color old = g.getColor(); g.setColor(bgColor); g.fillOval(dot0.x-4,dot0.y-4,8,8); g.setColor(old); g.drawOval(dot0.x-4,dot0.y-4,8,8); } else if (minArgDot.equals("closed")){ g.fillOval(dot0.x-4,dot0.y-4,8,8); g.drawOval(dot0.x-4,dot0.y-4,8,8); }else if(minArgDot.equals("arrow-like")){ drawArrow(g, dot0, derivXmin, arrowHadlePointsXmin); } } if (dot1 != null){ style.flush(g); if (maxArgDot.equals("opened") || maxArgDot.equals("open")) { Color old = g.getColor(); g.setColor(bgColor); g.fillOval(dot1.x-4,dot1.y-4,8,8); g.setColor(old); g.drawOval(dot1.x-4,dot1.y-4,8,8); } else if (maxArgDot.equals("closed")){ g.fillOval(dot1.x-4,dot1.y-4,8,8); g.drawOval(dot1.x-4,dot1.y-4,8,8); }else if(maxArgDot.equals("arrow-like")){ drawArrow(g, dot1, derivXmax, arrowHadlePointsXmax); } } } style.flush(g); g.setColor(oldColor); isUpdated = true; } }
this problem is in the following line of the code: if (fillPattern.equals((int[])fillPatterns.get("EMPTY"))) ;
proposed patch, sorry i didn't downloaded sdk yet, so i didn't verify it Index: CastExpression.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compi ler/ast/CastExpression.java,v retrieving revision 1.45 diff -u -r1.45 CastExpression.java --- CastExpression.java 22 Jul 2003 11:30:47 -0000 1.45 +++ CastExpression.java 25 Jul 2003 11:46:57 -0000 @@ -244,7 +244,7 @@ * Cast expressions will considered as useful if removing them all would actually bind to a different method * (no fine grain analysis on per casted argument basis, simply separate widening cast from narrowing ones) */ - public static void checkNeedForArgumentCasts(BlockScope scope, Expression receiver, ReferenceBinding receiverType, MethodBinding binding, Expression[] arguments, TypeBinding[] argumentTypes, final InvocationSite invocationSite) { + public static void checkNeedForArgumentCasts(BlockScope scope, Expression receiver, TypeBinding receiverType, MethodBinding binding, Expression [] arguments, TypeBinding[] argumentTypes, final InvocationSite invocationSite) { if (scope.environment().options.getSeverity (CompilerOptions.UnnecessaryTypeCheck) == ProblemSeverities.Ignore) return; @@ -346,7 +346,7 @@ } } - private static void checkAlternateBinding(BlockScope scope, Expression receiver, ReferenceBinding receiverType, MethodBinding binding, Expression[] arguments, TypeBinding[] originalArgumentTypes, TypeBinding[] alternateArgumentTypes, final InvocationSite invocationSite) { + private static void checkAlternateBinding(BlockScope scope, Expression receiver, TypeBinding receiverType, MethodBinding binding, Expression[] arguments, TypeBinding[] originalArgumentTypes, TypeBinding[] alternateArgumentTypes, final InvocationSite invocationSite) { InvocationSite fakeInvocationSite = new InvocationSite() { public boolean isSuperAccess(){ return invocationSite.isSuperAccess(); } @@ -357,7 +357,7 @@ }; MethodBinding bindingIfNoCast; if (binding.isConstructor()) { - bindingIfNoCast = scope.getConstructor (receiverType, alternateArgumentTypes, fakeInvocationSite); + bindingIfNoCast = scope.getConstructor ((ReferenceBinding)receiverType, alternateArgumentTypes, fakeInvocationSite); } else { bindingIfNoCast = receiver.isImplicitThis() ? scope.getImplicitMethod (binding.selector, alternateArgumentTypes, fakeInvocationSite) Index: MessageSend.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compi ler/ast/MessageSend.java,v retrieving revision 1.49 diff -u -r1.49 MessageSend.java --- MessageSend.java 22 Jul 2003 11:30:47 -0000 1.49 +++ MessageSend.java 25 Jul 2003 11:46:58 -0000 @@ -267,7 +267,7 @@ arguments[i].implicitWidening(binding.parameters[i], argumentTypes[i]); } if (containsCast) { - CastExpression.checkNeedForArgumentCasts(scope, this.receiver, (ReferenceBinding)receiverType, binding, this.arguments, argumentTypes, this); + CastExpression.checkNeedForArgumentCasts(scope, this.receiver, receiverType, binding, this.arguments, argumentTypes, this); } } //-------message send that are known to fail at compile time-----------
i put my current oth.eclipse.jdt.core (patched) to 3.0 M2 and it solved the problem.
Reproduced on simple test case: public class X { public void foo(Map map) { int[] fillPattern = new int[0]; if (fillPattern.equals((int[])map.get("x"))) { } } }
Contributed fix is good. Integrated. Regression test added.
Fixed
Thanks for the patch, makes our life much easier <g>
*** Bug 40953 has been marked as a duplicate of this bug. ***
Verified.