Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 236702

Summary: [quick fix] generate throws clause erases previous throws clause
Product: [Eclipse Project] JDT Reporter: Charlie Kelly <Eclipse>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: Eclipse, martinae
Version: 3.4   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug

Description Charlie Kelly CLA 2008-06-11 14:06:02 EDT
Build ID: I20080409-1425

Steps To Reproduce:
1. write a Java method that contains a throws clause in the method signature
2. add code to the method that throws an Exception not listed within the throws clause in the method signature
3. use the context menu to "add throws declaration"
4. existing Exception(s) are erased and only new Exception appears in method signature


More information:
Comment 1 Martin Aeschlimann CLA 2008-06-12 04:35:06 EDT
Can you give a reproducible example?
What you describe should only happen if the new thrown exception is a super class of the already thrown exception. In that case there's not need to throw both.
Comment 2 Charlie Kelly CLA 2008-06-12 10:31:07 EDT
(In reply to comment #1)
> Can you give a reproducible example?
> What you describe should only happen if the new thrown exception is a super
> class of the already thrown exception. In that case there's not need to throw
> both.
> 

If you remove the throws clause from the method signature, the Eclipse Java editor reports 2 errors (on the lines beginning "HyperSquareCharacteristics" and "this.centerHyperSquare").

If you request that Eclipse automatically correct the first error, it duplicates the method signature below.

However, if you request the Eclipse automatically correct the second error, the new throws declaration is "throws TupleException, Exception".

(I've included the code for TupleException and UtilityException at the bottom of this reply.)



private void prepareCenterHyperSquare() throws UtilityException, TupleException, Exception
	{
		int order = this.sudokuHyperSquareCharacteristics.getOrder();
		int dimensions = this.sudokuHyperSquareCharacteristics.getDimensions();		
		
		DirectionController directionController = new DirectionController(dimensions);		
		
		HyperSquareCharacteristics hyperSquareCharacteristics 
				= new HyperSquareCharacteristics (order, dimensions);		
		
		this.centerHyperSquare = new HyperSquare (hyperSquareCharacteristics, directionController);		
	}// private void prepareCenterHyperSquare() throws UtilityException, TupleException, Exception



package com.charliekelly.magicsudoku.model.tuple;

public class TupleException extends Exception
{
	private static final long	serialVersionUID	= 1L;
	////////////////////////////////////////////////////////////////////////////
	public TupleException (String message)
	{
		super(message);
	}// private static final long	serialVersionUID	= 1L;
	////////////////////////////////////////////////////////////////////////////
}// public class TupleException extends Exception



package com.charliekelly.magicsudoku.model.utility;

public class UtilityException extends Exception
{
	private static final long	serialVersionUID	= 1L;
	////////////////////////////////////////////////////////////////////////////
	public UtilityException (String message)
	{
		super(message);
	}// private static final long	serialVersionUID	= 1L;
	////////////////////////////////////////////////////////////////////////////
}// public class TupleException extends Exception
Comment 3 Eclipse Genie CLA 2020-03-05 17:34:22 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.