8240261: Use make/templates/gpl-cp-header in FieldGen.java
Reviewed-by: erikj
This commit is contained in:
parent
19e02810db
commit
0368e41c12
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 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
|
||||
@ -101,7 +101,7 @@ GENSRC_JAVA_BASE += $(GENSRC_LSREQUIVMAPS)
|
||||
################################################################################
|
||||
|
||||
INTPOLY_GEN_DONE := $(GENSRC_DIR)/_intpoly-gensrc.marker
|
||||
INTPOLY_HEADER := $(TOPDIR)/make/jdk/src/classes/build/tools/intpoly/header.txt
|
||||
INTPOLY_HEADER := $(TOPDIR)/make/templates/gpl-cp-header
|
||||
$(INTPOLY_GEN_DONE): $(INTPLOY_HEADER) $(BUILD_TOOLS_JDK)
|
||||
$(call MakeDir, $(GENSRC_DIR))
|
||||
$(call LogInfo, Generating fixed-field math classes for java.base)
|
||||
|
@ -1,10 +1,12 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
@ -21,12 +23,13 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* This file is used to generated optimized finite field implementations.
|
||||
*/
|
||||
package build.tools.intpoly;
|
||||
|
||||
import build.tools.util.Header;
|
||||
|
||||
import java.io.*;
|
||||
import java.math.BigInteger;
|
||||
import java.nio.file.Files;
|
||||
@ -584,8 +587,16 @@ public class FieldGen {
|
||||
|
||||
private String generate(FieldParams params) throws IOException {
|
||||
CodeBuffer result = new CodeBuffer();
|
||||
String header = readHeader();
|
||||
result.appendLine(header);
|
||||
for (String line : Header.javaHeader(headerPath)) {
|
||||
result.appendLine(line);
|
||||
}
|
||||
|
||||
result.appendLine();
|
||||
result.appendLine("/*");
|
||||
result.appendLine(" * This file is generated by FieldGen.java. "
|
||||
+ "Do not modify it directly.");
|
||||
result.appendLine(" */");
|
||||
result.appendLine();
|
||||
|
||||
if (packageName != null) {
|
||||
result.appendLine("package " + packageName + ";");
|
||||
@ -910,12 +921,4 @@ public class FieldGen {
|
||||
result.freeTemporary(temp);
|
||||
}
|
||||
}
|
||||
|
||||
private String readHeader() throws IOException {
|
||||
BufferedReader reader
|
||||
= Files.newBufferedReader(headerPath);
|
||||
StringBuffer result = new StringBuffer();
|
||||
reader.lines().forEach(s -> result.append(s + "\n"));
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
|
@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is generated by FieldGen.java. Do not modify it directly.
|
||||
*/
|
64
make/jdk/src/classes/build/tools/util/Header.java
Normal file
64
make/jdk/src/classes/build/tools/util/Header.java
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package build.tools.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Header {
|
||||
|
||||
// template: a file inside make/template/
|
||||
// years: "2020," or "2000, 2020,"
|
||||
public static List<String> javaHeader(Path template, String years)
|
||||
throws IOException {
|
||||
List<String> result = new ArrayList<>();
|
||||
result.add("/*");
|
||||
int emptyLines = 0;
|
||||
for (String line : Files.readAllLines(template)) {
|
||||
if (line.isEmpty()) {
|
||||
emptyLines++;
|
||||
} else {
|
||||
// Only add empty lines when they are not at the end
|
||||
for (int i = 0; i < emptyLines; i++) {
|
||||
result.add(" *");
|
||||
}
|
||||
emptyLines = 0;
|
||||
result.add(" * " + line.replace("%YEARS%", years));
|
||||
}
|
||||
}
|
||||
result.add(" */");
|
||||
return result;
|
||||
}
|
||||
|
||||
public static List<String> javaHeader(Path template)
|
||||
throws IOException {
|
||||
return javaHeader(template, LocalDate.now().getYear() + ",");
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user