Skip to content
This repository was archived by the owner on Sep 24, 2018. It is now read-only.
This repository was archived by the owner on Sep 24, 2018. It is now read-only.

Remove checked Exception from ObjectFactory factory methods #45

@glassfishrobot

Description

@glassfishrobot

There is a request for JAXB 2.0 to no longer require that
the factory method signatures in ObjectFactory throw the
checked exception JAXBException.

Rationale:
In Java, creating new instances of objects do not fail with a
checked exception. This is because:

  • it's not hard to imagine how many try-catch blocks you'll
    be writing if every "new" throws an exception.
  • unlike errors like I/O problems, which you can handle gracefully,
    there's really nothing you can do to recover from failing to
    create new instances in memory.

Specific request is to change following text in Section 5.2 of JAXB 2.0 Early
Draft

A public class ObjectFactory contains:
An instance factory method signature for each Java content within the package.

Given Java content interface named Foo, here is the derived factory method:

public Foo createFoo() throws JAXBException;
An element instance factory method signature for each bound element declaration.

public IXmlElement createFoo(T elementValue)
throws JAXBException;
Dynamic instance factory allocator method signature:

public Object newInstance(Class javaContentInterface)
throws JAXBException;

Change is to delete "throws JAXBException" from above factory method
signatures of ObjectFactory.

Environment

Operating System: All
Platform: All

Affected Versions

[2.0 draft]

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions