René's URL Explorer Experiment


Title: Upstream Bug: JsonNumber.of(double) hardcodes decimalOffset causing toLong to fail · Issue #118 · simbo1905/java.util.json.Java21 · GitHub

Open Graph Title: Upstream Bug: JsonNumber.of(double) hardcodes decimalOffset causing toLong to fail · Issue #118 · simbo1905/java.util.json.Java21

X Title: Upstream Bug: JsonNumber.of(double) hardcodes decimalOffset causing toLong to fail · Issue #118 · simbo1905/java.util.json.Java21

Description: Summary The JsonNumber.of(double) factory method has a bug where it hardcodes decimalOffset=0 and exponentOffset=0 when creating the JsonNumberImpl. This causes toLong() to fail for integral doubles like 123.0. Root Cause In JsonNumber.j...

Open Graph Description: Summary The JsonNumber.of(double) factory method has a bug where it hardcodes decimalOffset=0 and exponentOffset=0 when creating the JsonNumberImpl. This causes toLong() to fail for integral double...

X Description: Summary The JsonNumber.of(double) factory method has a bug where it hardcodes decimalOffset=0 and exponentOffset=0 when creating the JsonNumberImpl. This causes toLong() to fail for integral double...

Opengraph URL: https://github.com/simbo1905/java.util.json.Java21/issues/118

X: @github

direct link

Domain: patch-diff.githubusercontent.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Upstream Bug: JsonNumber.of(double) hardcodes decimalOffset causing toLong to fail","articleBody":"## Summary\n\nThe `JsonNumber.of(double)` factory method has a bug where it hardcodes `decimalOffset=0` and `exponentOffset=0` when creating the `JsonNumberImpl`. This causes `toLong()` to fail for integral doubles like `123.0`.\n\n## Root Cause\n\nIn `JsonNumber.java` line 117:\n```java\nstatic JsonNumber of(double num) {\n    if (!Double.isFinite(num)) {\n        throw new IllegalArgumentException(\"Not a valid JSON number\");\n    }\n    var str = Double.toString(num);\n    return new JsonNumberImpl(str.toCharArray(), 0, str.length(), 0, 0);\n    //                                                           ^^^^^ BUG: hardcoded offsets\n}\n```\n\nFor `Double.toString(123.0)` which returns `\"123.0\"`:\n- `decimalOffset` should be `3` (position of `.`) but is passed as `0`\n- This causes `initNumLong()` in `JsonNumberImpl` to misparse the number\n\n## Reproduction\n\n```java\nvar jn = JsonNumber.of(123.0);\njn.toString();  // \"123.0\" - OK\njn.toDouble();  // 123.0 - OK\njn.toLong();    // THROWS: \"123.0 cannot be represented as a long\"\n                // EXPECTED: 123L (per API docs, \"123.0\" should be convertible)\n```\n\n## Comparison with Json.parse()\n\n```java\nvar parsed = Json.parse(\"123.0\");\nparsed.toLong();  // 123L - WORKS correctly\n```\n\nThe difference is that `Json.parse()` correctly computes the `decimalOffset` during parsing.\n\n## Suggested Fix\n\nOption 1 - Reuse `JsonNumber.of(String)` which delegates to parser:\n```java\nstatic JsonNumber of(double num) {\n    if (!Double.isFinite(num)) {\n        throw new IllegalArgumentException(\"Not a valid JSON number\");\n    }\n    return JsonNumber.of(Double.toString(num));\n}\n```\n\nOption 2 - Compute correct offsets:\n```java\nstatic JsonNumber of(double num) {\n    if (!Double.isFinite(num)) {\n        throw new IllegalArgumentException(\"Not a valid JSON number\");\n    }\n    var str = Double.toString(num);\n    var chars = str.toCharArray();\n    int dec = str.indexOf('.');\n    int exp = str.indexOf('e');\n    if (exp == -1) exp = str.indexOf('E');\n    return new JsonNumberImpl(chars, 0, chars.length, \n        dec == -1 ? -1 : dec, \n        exp == -1 ? -1 : exp);\n}\n```\n\n## This is an Upstream Bug\n\nThis bug exists in OpenJDK jdk-sandbox `json` branch at commit `91a479d`. The upstream tests in `TestJsonNumber.java` do not cover this case - they test `of(double).toDouble()` but never `of(double).toLong()` for integral doubles.\n\n## Affected Versions\n\n- jdk-sandbox json branch (upstream)\n- java.util.json.Java21 backport 0.1.9 (this repo, synced from upstream)\n","author":{"url":"https://github.com/simbo1905","@type":"Person","name":"simbo1905"},"datePublished":"2026-01-26T00:14:19.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/118/java.util.json.Java21/issues/118"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:97fc7675-4863-d867-9cda-b0271089f280
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBF9E:3CAE76:79152DD:9CD1EC7:697E601E
html-safe-noncef792050a59b5cbf92b7d90cda543e7b9792aaca1d58cd6a58f23e5ee4eec8739
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRjlFOjNDQUU3Njo3OTE1MkREOjlDRDFFQzc6Njk3RTYwMUUiLCJ2aXNpdG9yX2lkIjoiNjgzNTQzMjEzNzA0NjM0Mzk4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacc1b421a22352de7561ac6fd553db763ae5df5b9ccbf20d965cdb82f908ce0ca0
hovercard-subject-tagissue:3854068458
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/simbo1905/java.util.json.Java21/118/issue_layout
twitter:imagehttps://opengraph.githubassets.com/34d75fda6b18ff4b92eff9fac4424835bae2b336b675195ba90d6d6123242394/simbo1905/java.util.json.Java21/issues/118
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/34d75fda6b18ff4b92eff9fac4424835bae2b336b675195ba90d6d6123242394/simbo1905/java.util.json.Java21/issues/118
og:image:altSummary The JsonNumber.of(double) factory method has a bug where it hardcodes decimalOffset=0 and exponentOffset=0 when creating the JsonNumberImpl. This causes toLong() to fail for integral double...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamesimbo1905
hostnamegithub.com
expected-hostnamegithub.com
None60279d4097367e16897439d16d6bbe4180663db828c666eeed2656988ffe59f6
turbo-cache-controlno-preview
go-importgithub.com/simbo1905/java.util.json.Java21 git https://github.com/simbo1905/java.util.json.Java21.git
octolytics-dimension-user_id322608
octolytics-dimension-user_loginsimbo1905
octolytics-dimension-repository_id1025867939
octolytics-dimension-repository_nwosimbo1905/java.util.json.Java21
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1025867939
octolytics-dimension-repository_network_root_nwosimbo1905/java.util.json.Java21
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release7c85641c598ad130c74f7bcc27f58575cac69551
ui-targetcanary-1
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/simbo1905/java.util.json.Java21/issues/118#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimbo1905%2Fjava.util.json.Java21%2Fissues%2F118
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimbo1905%2Fjava.util.json.Java21%2Fissues%2F118
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=simbo1905%2Fjava.util.json.Java21
Reloadhttps://patch-diff.githubusercontent.com/simbo1905/java.util.json.Java21/issues/118
Reloadhttps://patch-diff.githubusercontent.com/simbo1905/java.util.json.Java21/issues/118
Reloadhttps://patch-diff.githubusercontent.com/simbo1905/java.util.json.Java21/issues/118
simbo1905 https://patch-diff.githubusercontent.com/simbo1905
java.util.json.Java21https://patch-diff.githubusercontent.com/simbo1905/java.util.json.Java21
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2Fsimbo1905%2Fjava.util.json.Java21
Fork 0 https://patch-diff.githubusercontent.com/login?return_to=%2Fsimbo1905%2Fjava.util.json.Java21
Star 1 https://patch-diff.githubusercontent.com/login?return_to=%2Fsimbo1905%2Fjava.util.json.Java21
Code https://patch-diff.githubusercontent.com/simbo1905/java.util.json.Java21
Issues 5 https://patch-diff.githubusercontent.com/simbo1905/java.util.json.Java21/issues
Pull requests 3 https://patch-diff.githubusercontent.com/simbo1905/java.util.json.Java21/pulls
Actions https://patch-diff.githubusercontent.com/simbo1905/java.util.json.Java21/actions
Projects 0 https://patch-diff.githubusercontent.com/simbo1905/java.util.json.Java21/projects
Security 0 https://patch-diff.githubusercontent.com/simbo1905/java.util.json.Java21/security
Insights https://patch-diff.githubusercontent.com/simbo1905/java.util.json.Java21/pulse
Code https://patch-diff.githubusercontent.com/simbo1905/java.util.json.Java21
Issues https://patch-diff.githubusercontent.com/simbo1905/java.util.json.Java21/issues
Pull requests https://patch-diff.githubusercontent.com/simbo1905/java.util.json.Java21/pulls
Actions https://patch-diff.githubusercontent.com/simbo1905/java.util.json.Java21/actions
Projects https://patch-diff.githubusercontent.com/simbo1905/java.util.json.Java21/projects
Security https://patch-diff.githubusercontent.com/simbo1905/java.util.json.Java21/security
Insights https://patch-diff.githubusercontent.com/simbo1905/java.util.json.Java21/pulse
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/simbo1905/java.util.json.Java21/issues/118
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/simbo1905/java.util.json.Java21/issues/118
Upstream Bug: JsonNumber.of(double) hardcodes decimalOffset causing toLong to failhttps://patch-diff.githubusercontent.com/simbo1905/java.util.json.Java21/issues/118#top
https://github.com/simbo1905
https://github.com/simbo1905
simbo1905https://github.com/simbo1905
on Jan 26, 2026https://github.com/simbo1905/java.util.json.Java21/issues/118#issue-3854068458
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.