Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6836883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:24:34+00:00 2026-05-26T23:24:34+00:00

I’m getting a Null Pointer Exception while in executing a macro to do some

  • 0

I’m getting a Null Pointer Exception while in executing a macro to do some Java interop, and I can’t figure out why.

I’m setting the fields of a Java object using a map with nested data, and since the names of the map keys are the same as the field names of the object, I created a macro:

(defmacro set-keys! [pose m k klst]
  `(set! (. ~pose ~(symbol (name k)))
         (double-array (map #(% (~(keyword (name k)) ~m)) ~klst))))

For testing, I defined pse to be an initialized Java object with the fields of interest set to zero, and I defined mp as a simplified map that would still work:

(def mp {:pos {:x 1 :y 2})

Now comes the odd behavior. Executing set-keys! with explicitly typed arguments works:

user> (set-keys! pse mp :pos [:x :y])
#<double[] [D@691ba57a>

But if I use run the code in a inside a let call:

user> (let [x :pos y [:x :y]]
        (set-keys! pse mp x y))

I get a Null Pointer Exception with “No message.” as the message. What is the issue here?

EDIT: I defined pse with (def pse (pose_t.)), pose_t is a generated class, and the pose_t() constructor initializes all the arrays in its fields, but doesn’t initialize the values. The relevant lines of the class code for the simplified example are:

public double pos[];

public pose_t() {
    pos = new double[3];
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:24:34+00:00Added an answer on May 26, 2026 at 11:24 pm

    Macro arguments are not evaluated, so ~(keyword (name k)) expands to – roughly – (keyword (name (quote x))) – which is :x, not :pos

    At least I guess that’s the problem. If not, it would be nice if you could include a definition for pse.

    Addendum: you can inspect what the macro is actually expanding to by evaluating:

    user> (macroexpand-1 '(set-keys! pse mp x y))
    (set! (. pse x) (clojure.core/double-array (clojure.core/map
        (fn* [p1__2066__2067__auto__] (p1__2066__2067__auto__ (:x mp))) y)))
    

    Note the 😡

    Addendum 2: (. obj field) actually also doesn’t evaluate field, meaning you’d have to use java reflection to make the field argument dynamic.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Does anyone know how can I replace this 2 symbol below from the string
I have thousands of HTML files to process using Groovy/Java and I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.