Skip to content

Commit

Permalink
8250855: Address reliance on default constructors in the Java 2D APIs
Browse files Browse the repository at this point in the history
Reviewed-by: prr, serb
  • Loading branch information
c-cleary authored and prrace committed Sep 24, 2020
1 parent a9d0440 commit 3495c19
Show file tree
Hide file tree
Showing 14 changed files with 85 additions and 14 deletions.
7 changes: 6 additions & 1 deletion src/java.desktop/share/classes/java/awt/Image.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -45,6 +45,11 @@
*/
public abstract class Image {

/**
* Constructor for subclasses to call.
*/
protected Image() {}

/**
* convenience object; we can use this single static object for
* all images that do not create their own image caps; it holds the
Expand Down
7 changes: 6 additions & 1 deletion src/java.desktop/share/classes/java/awt/PrintJob.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -36,6 +36,11 @@
*/
public abstract class PrintJob {

/**
* Constructor for subclasses to call.
*/
protected PrintJob() {}

/**
* Gets a Graphics object that will draw to the next page.
* The page is sent to the printer when the graphics
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -108,6 +108,11 @@

public abstract class GlyphVector implements Cloneable {

/**
* Constructor for subclasses to call.
*/
protected GlyphVector() {}

//
// methods associated with creation-time state
//
Expand Down
8 changes: 7 additions & 1 deletion src/java.desktop/share/classes/java/awt/font/LayoutPath.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -41,6 +41,12 @@
* @since 1.6
*/
public abstract class LayoutPath {

/**
* Constructor for subclasses to call.
*/
protected LayoutPath() {}

/**
* Convert a point in user space to a location relative to the
* path. The location is chosen so as to minimize the distance
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -43,6 +43,10 @@

public abstract class LineMetrics {

/**
* Constructor for subclasses to call.
*/
protected LineMetrics() {}

/**
* Returns the number of characters ({@code char} values) in the text whose
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -65,6 +65,11 @@
public abstract class AbstractMultiResolutionImage extends java.awt.Image
implements MultiResolutionImage {

/**
* Constructor for subclasses to call.
*/
protected AbstractMultiResolutionImage() {}

/**
* This method simply delegates to the same method on the base image and
* it is equivalent to: {@code getBaseImage().getWidth(observer)}.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -134,6 +134,11 @@
*/
public abstract class BufferStrategy {

/**
* Constructor for subclasses to call.
*/
protected BufferStrategy() {}

/**
* Returns the {@code BufferCapabilities} for this
* {@code BufferStrategy}.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -43,6 +43,12 @@
* @author Jim Graham
*/
public class ImageFilter implements ImageConsumer, Cloneable {

/**
* Constructs an {@code ImageFilter}.
*/
public ImageFilter() {}

/**
* The consumer of the particular image data stream for which this
* instance of the ImageFilter is filtering data. It is not
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -66,6 +66,11 @@
*/
public abstract class RGBImageFilter extends ImageFilter {

/**
* Constructor for subclasses to call.
*/
protected RGBImageFilter() {}

/**
* The {@code ColorModel} to be replaced by
* {@code newmodel} when the user calls
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -133,6 +133,11 @@
public abstract class VolatileImage extends Image implements Transparency
{

/**
* Constructor for subclasses to call.
*/
protected VolatileImage() {}

// Return codes for validate() method

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -65,6 +65,11 @@
*/
public abstract class PrintServiceLookup {

/**
* Constructor for subclasses to call.
*/
protected PrintServiceLookup() {}

/**
* Contains a lists of services.
*/
Expand Down
7 changes: 6 additions & 1 deletion src/java.desktop/share/classes/javax/print/ServiceUI.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -65,6 +65,11 @@
*/
public class ServiceUI {

/**
* Constructs a {@code ServiceUI}.
*/
public ServiceUI() {}

/**
* Presents a dialog to the user for selecting a print service (printer). It
* is displayed at the location specified by the application and is modal.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -56,6 +56,11 @@
*/
public abstract class ServiceUIFactory {

/**
* Constructor for subclasses to call.
*/
protected ServiceUIFactory() {}

/**
* Denotes a UI implemented as a Swing component. The value of the string is
* the fully qualified classname : "javax.swing.JComponent".
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -36,6 +36,11 @@
*/
public abstract class PrintJobAdapter implements PrintJobListener {

/**
* Constructor for subclasses to call.
*/
protected PrintJobAdapter() {}

/**
* Called to notify the client that data has been successfully transferred
* to the print service, and the client may free local resources allocated
Expand Down

1 comment on commit 3495c19

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on 3495c19 Sep 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.