Skip to content

Commit 737bd0e

Browse files
committed
make the backend an interface
1 parent 4ed1b1a commit 737bd0e

3 files changed

Lines changed: 14 additions & 18 deletions

File tree

src/changes/changes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
<body>
1010
<release version="5.4.0" date="August xx, 2026" description="Chrome/Edge 150, Bugfixes">
11+
<action type="update" dev="rhino">
12+
The url/anchor hostname setter handling got some fixes.
13+
</action>
1114
<action type="update" dev="rbri" due-to="Lai Quang Duong">
1215
core-js: support for a common workaround for subclassing built-in objects (like Set) without
1316
using ES6 class/extends syntax, by using Reflect.construct() with a newTarget argument added.

src/main/java/org/htmlunit/javascript/host/file/Blob.java

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,44 +61,44 @@ public class Blob extends HtmlUnitScriptable {
6161
/**
6262
* The backend used for saving the blob.
6363
*/
64-
protected abstract static class Backend implements Serializable {
64+
protected interface Backend extends Serializable {
6565

6666
/**
6767
* Returns the name.
6868
*
6969
* @return the name
7070
*/
71-
abstract String getName();
71+
String getName();
7272

7373
/**
7474
* Returns the last modified timestamp as long.
7575
*
7676
* @return the last modified timestamp as long
7777
*/
78-
abstract long getLastModified();
78+
long getLastModified();
7979

8080
/**
8181
* Returns the size.
8282
*
8383
* @return the size
8484
*/
85-
abstract long getSize();
85+
long getSize();
8686

8787
/**
8888
* Returns the type.
8989
*
9090
* @param browserVersion the {@link BrowserVersion}
9191
* @return the type
9292
*/
93-
abstract String getType(BrowserVersion browserVersion);
93+
String getType(BrowserVersion browserVersion);
9494

9595
/**
9696
* Returns the text.
9797
*
9898
* @return the text
9999
* @throws IOException in case of error
100100
*/
101-
abstract String getText() throws IOException;
101+
String getText() throws IOException;
102102

103103
/**
104104
* Returns the bytes.
@@ -107,14 +107,7 @@ protected abstract static class Backend implements Serializable {
107107
* @param end the end position
108108
* @return the bytes
109109
*/
110-
abstract byte[] getBytes(int start, int end);
111-
112-
/**
113-
* Ctor.
114-
*/
115-
Backend() {
116-
// to make it package protected
117-
}
110+
byte[] getBytes(int start, int end);
118111

119112
/**
120113
* Returns the KeyDataPair for this Blob/File.
@@ -124,14 +117,14 @@ protected abstract static class Backend implements Serializable {
124117
* @param contentType the content type
125118
* @return the KeyDataPair to hold the data
126119
*/
127-
abstract KeyDataPair getKeyDataPair(String name, String fileName, String contentType);
120+
KeyDataPair getKeyDataPair(String name, String fileName, String contentType);
128121
}
129122

130123
/**
131124
* Implementation of the {@link Backend} that stores the bytes in memory.
132125
*
133126
*/
134-
protected static class InMemoryBackend extends Backend {
127+
protected static class InMemoryBackend implements Backend {
135128
private final String fileName_;
136129
private final String type_;
137130
private final long lastModified_;

src/main/java/org/htmlunit/javascript/host/file/File.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class File extends Blob {
5050
private static final DateTimeFormatter LAST_MODIFIED_DATE_FORMATTER
5151
= DateTimeFormatter.ofPattern("EEE MMM dd yyyy HH:mm:ss 'GMT'Z");
5252

53-
private static class FileBackend extends Backend {
53+
private static class FileBackend implements Backend {
5454
private static final Log LOG = LogFactory.getLog(FileBackend.class);
5555

5656
private final java.io.File file_;
@@ -86,7 +86,7 @@ public String getText() throws IOException {
8686
}
8787

8888
@Override
89-
byte[] getBytes(final int start, final int end) {
89+
public byte[] getBytes(final int start, final int end) {
9090
final byte[] result = new byte[end - start];
9191
try {
9292
System.arraycopy(FileUtils.readFileToByteArray(file_), start, result, 0, result.length);

0 commit comments

Comments
 (0)