Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Compilation problem with exceptions(no add throws multiple exceptions, no fix coalesce catch clauses)
Compilation problem with exceptions [message #1787069] Fri, 18 May 2018 10:38
Oleg S. is currently offline Oleg S.Friend
Messages: 1
Registered: May 2018
Junior Member
Version: Oxygen.3a Release (4.7.3a)
Build id: 20180405-1200

1) there is code:

import java.io.IOException;
import java.sql.SQLException;

public class  MyClass1 {

	public static void main(String[] args){
		try {
			if(System.nanoTime() % 2 == 0) {
				throw new IOException();
			}else {
				throw new SQLException();
			}
		}catch(Exception e) {
			throw e;
		}		
	}
}


the compiler offers fix "Add throws declaration" as "throws Exception", but expected "throws SQLException, IOException".



2) there is code:

import java.io.IOException;
import java.sql.SQLException;

public class MyClass2 {
    public static void main(String[] args) {
        try{
            if(System.nanoTime() % 2 == 0){
                throw new IOException();
            }else{
                throw new SQLException();
            }
        }catch(IOException e){
        
        }catch(SQLException e){
        
        }
    }
}


expected fix with using multi-cacth sintax, but compiler offers nothing.

how can we fix this?
Previous Topic:Simple compilation fails in Eclipse Oxygen.3a
Next Topic:Eclipse Oxygen 2.0 MAF Application
Goto Forum:
  


Current Time: Thu Sep 20 16:05:33 GMT 2018

Powered by FUDForum. Page generated in 0.02143 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top