Skip to content

Commit 68c1d30

Browse files
committed
8357287: Unify usage of ICC profile "header size" constants in CMM-related code
Reviewed-by: honkar, prr
1 parent 3bebb1f commit 68c1d30

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/java.desktop/share/classes/java/awt/color/ICC_Profile.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
import sun.java2d.cmm.ProfileDataVerifier;
5858
import sun.java2d.cmm.ProfileDeferralInfo;
5959

60+
import static sun.java2d.cmm.ProfileDataVerifier.HEADER_SIZE;
61+
6062
/**
6163
* A representation of color profile data for device independent and device
6264
* dependent color spaces based on the International Color Consortium
@@ -764,8 +766,6 @@ private interface BuiltInProfile {
764766
*/
765767
public static final int icXYZNumberX = 8;
766768

767-
private static final int HEADER_SIZE = 128;
768-
769769
/**
770770
* Constructs an {@code ICC_Profile} object with a given ID.
771771
*/
@@ -913,11 +913,11 @@ public static ICC_Profile getInstance(InputStream s) throws IOException {
913913

914914
static byte[] getProfileDataFromStream(InputStream s) throws IOException {
915915
BufferedInputStream bis = new BufferedInputStream(s);
916-
bis.mark(128); // 128 is the length of the ICC profile header
916+
bis.mark(HEADER_SIZE);
917917

918-
byte[] header = bis.readNBytes(128);
919-
if (header.length < 128 || header[36] != 0x61 || header[37] != 0x63 ||
920-
header[38] != 0x73 || header[39] != 0x70) {
918+
byte[] header = bis.readNBytes(HEADER_SIZE);
919+
if (header.length < HEADER_SIZE || header[36] != 0x61 ||
920+
header[37] != 0x63 || header[38] != 0x73 || header[39] != 0x70) {
921921
return null; /* not a valid profile */
922922
}
923923
int profileSize = intFromBigEndian(header, 0);

src/java.desktop/share/classes/sun/java2d/cmm/ProfileDataVerifier.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -106,7 +106,7 @@ private static int readInt32(byte[] data, int off) {
106106
*/
107107
private static final int MAX_TAG_COUNT = 100;
108108

109-
private static final int HEADER_SIZE = 128;
109+
public static final int HEADER_SIZE = 128;
110110
private static final int TOC_OFFSET = HEADER_SIZE + 4;
111111
private static final int TOC_RECORD_SIZE = 12;
112112

0 commit comments

Comments
 (0)