Skip to content
Permalink
Browse files

8223536: jdk/javadoc/doclet/MetaTag/MetaTag.java still fails when run…

… across midnight

Reviewed-by: prappo
  • Loading branch information
jonathan-gibbons committed Jan 15, 2020
1 parent 45bc387 commit 642037eee8c5bf63e7c05d9b018743f7d5ea08c3
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2019, 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
@@ -262,6 +262,7 @@ public HtmlConfiguration(Doclet doclet) {
private static final String versionBundleName = "jdk.javadoc.internal.tool.resources.version";
private static final String defaultDocletVersion = System.getProperty("java.version");
public final String docletVersion;
public final Date startTime = new Date();

@Override
public String getDocletVersion() {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2019, 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
@@ -447,7 +447,7 @@ public void printHtmlDocument(List<String> metakeywords,
Content htmlComment = contents.newPage;
List<DocPath> additionalStylesheets = configuration.getAdditionalStylesheets();
additionalStylesheets.addAll(localStylesheets);
Head head = new Head(path, configuration.docletVersion)
Head head = new Head(path, configuration.docletVersion, configuration.startTime)
.setTimestamp(!configuration.notimestamp)
.setDescription(description)
.setGenerator(getGenerator(getClass()))
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 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
@@ -74,7 +74,7 @@ private IndexRedirectWriter(HtmlConfiguration configuration, DocPath filename, D
*/
private void generateIndexFile() throws DocFileIOException {
Content htmlComment = contents.newPage;
Head head = new Head(path, configuration.docletVersion)
Head head = new Head(path, configuration.docletVersion, configuration.startTime)
.setTimestamp(!configuration.notimestamp)
.setDescription("index redirect")
.setGenerator(getGenerator(getClass()))
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 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
@@ -235,7 +235,7 @@ public void convertClass(TypeElement te, DocPath outputdir)
* @param path the path for the file.
*/
private void writeToFile(Content body, DocPath path, TypeElement te) throws DocFileIOException {
Head head = new Head(path, configuration.docletVersion)
Head head = new Head(path, configuration.docletVersion, configuration.startTime)
// .setTimestamp(!configuration.notimestamp) // temporary: compatibility!
.setTitle(resources.getText("doclet.Window_Source_title"))
// .setCharset(configuration.charset) // temporary: compatibility!
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
@@ -28,15 +28,11 @@
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.TimeZone;

import jdk.javadoc.internal.doclets.toolkit.Content;
import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;

@@ -52,6 +48,7 @@
*/
public class Head {
private final String docletVersion;
private final Date generatedDate;
private final DocPath pathToRoot;
private String title;
private String charset;
@@ -68,8 +65,6 @@
private boolean addDefaultScript = true;
private DocPath canonicalLink;

private static final Calendar calendar = new GregorianCalendar(TimeZone.getDefault());

/**
* Creates a {@code Head} object, for a given file and HTML version.
* The file is used to help determine the relative paths to stylesheet and script files.
@@ -79,8 +74,9 @@
* @param path the path for the file that will include this HEAD element
* @param docletVersion a string identifying the doclet version
*/
public Head(DocPath path, String docletVersion) {
public Head(DocPath path, String docletVersion, Date generatedDate) {
this.docletVersion = docletVersion;
this.generatedDate = generatedDate;
pathToRoot = path.parent().invert();
keywords = new ArrayList<>();
scripts = new ArrayList<>();
@@ -215,7 +211,7 @@ public Head addDefaultScript(boolean addDefaultScript) {
* Specifies a value for a
* <a href="https://en.wikipedia.org/wiki/Canonical_link_element">canonical link</a>
* in the {@code <head>} element.
* @param link
* @param link the value for the canonical link
*/
public void setCanonicalLink(DocPath link) {
this.canonicalLink = link;
@@ -238,10 +234,8 @@ public Head addContent(Content... contents) {
* @return the HTML
*/
public Content toContent() {
Date now = showTimestamp ? calendar.getTime() : null;

HtmlTree tree = new HtmlTree(HtmlTag.HEAD);
tree.add(getGeneratedBy(showTimestamp, now));
tree.add(getGeneratedBy(showTimestamp, generatedDate));
tree.add(HtmlTree.TITLE(title));

if (charset != null) { // compatibility; should this be allowed?
@@ -250,7 +244,7 @@ public Content toContent() {

if (showTimestamp) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
tree.add(HtmlTree.META("dc.created", dateFormat.format(now)));
tree.add(HtmlTree.META("dc.created", dateFormat.format(generatedDate)));
}

if (description != null) {
@@ -317,7 +311,7 @@ private void addScripts(HtmlTree tree) {
mainBodyScript.append("var pathtoroot = ")
.appendStringLiteral(ptrPath + "/")
.append(";\n")
.append("loadScripts(document, \'script\');");
.append("loadScripts(document, 'script');");
}
addJQueryFile(tree, DocPaths.JSZIP_MIN);
addJQueryFile(tree, DocPaths.JSZIPUTILS_MIN);

0 comments on commit 642037e

Please sign in to comment.
You can’t perform that action at this time.