Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8273140: Replace usages of Enum.class.getEnumConstants() with Enum.values() where possible #5303

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/java.desktop/share/classes/sun/font/AttributeValues.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
stsypanov marked this conversation as resolved.
Show resolved Hide resolved
* Copyright (c) 2004, 2021, 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 @@ -211,7 +211,7 @@ public static int getMask(EAttribute ... atts) {
}

public static final int MASK_ALL =
getMask(EAttribute.class.getEnumConstants());
getMask(EAttribute.values());

public void unsetDefault() {
defined &= nondefault;
Expand Down
4 changes: 2 additions & 2 deletions src/java.desktop/share/classes/sun/font/EAttribute.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) 2021, Oracle and/or its affiliates. All rights reserved.
kevinrushforth marked this conversation as resolved.
Show resolved Hide resolved
* 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 @@ -75,7 +75,7 @@ public enum EAttribute {
att = ta;
}

/* package */ static final EAttribute[] atts = EAttribute.class.getEnumConstants();
/* package */ static final EAttribute[] atts = EAttribute.values();

public static EAttribute forAttribute(Attribute ta) {
for (EAttribute ea: atts) {
Expand Down
8 changes: 4 additions & 4 deletions src/java.sql/share/classes/java/sql/JDBCType.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
kevinrushforth marked this conversation as resolved.
Show resolved Hide resolved
* 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 @@ -206,7 +206,7 @@ public enum JDBCType implements SQLType {
* The Integer value for the JDBCType. It maps to a value in
* {@code Types.java}
*/
private Integer type;
private final Integer type;

/**
* Constructor to specify the data type value from {@code Types) for
Expand Down Expand Up @@ -251,8 +251,8 @@ public Integer getVendorTypeNumber() {
* @see Types
*/
public static JDBCType valueOf(int type) {
for( JDBCType sqlType : JDBCType.class.getEnumConstants()) {
if(type == sqlType.type)
for (JDBCType sqlType : JDBCType.values()) {
if (type == sqlType.type)
return sqlType;
}
throw new IllegalArgumentException("Type:" + type + " is not a valid "
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2021, 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 @@ -169,7 +169,7 @@ public String toString() {
};

public static AccessModifier getRandomAccessModifier(Random rnd) {
AccessModifier[] a = AccessModifier.class.getEnumConstants();
AccessModifier[] a = AccessModifier.values();
return a[rnd.nextInt(a.length)];
}
}
Expand Down Expand Up @@ -198,8 +198,6 @@ public String toString() {
}
}

;

public String init(Random rnd) {
switch (this) {
case LONG:
Expand All @@ -222,7 +220,7 @@ public String init(Random rnd) {
}

public static Type getRandomType(Random rnd) {
Type[] a = Type.class.getEnumConstants();
Type[] a = Type.values();
return a[rnd.nextInt(a.length)];
}
}