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

  • Home
  • SEARCH
  • 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 1060979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:24:32+00:00 2026-05-16T18:24:32+00:00

I made a little app to generate Java test classes based on certain set

  • 0

I made a little app to generate Java test classes based on certain set of information. Basically, I am generating the boilerplate code needed for a library that we are using.

I would like to test the generated code in better way than just comparing the output to an expected string.

  • Is there any facility to test if the Java code contains errors?
  • Is there any facility to determine if the Java file will compile?
  • Is there a strategy that I should use for this kind of situation (I was thinking of using Class class to get information about the class)?
  • 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-16T18:24:33+00:00Added an answer on May 16, 2026 at 6:24 pm
    • Is there any facility to test if the Java code contains errors?

    • Is there any facility to determine if the Java file will compile?

    • Is there a strategy that I should use for this kind of situation?

    Yes – compile the file with the Java compiler.

    Note that you can call the Java compiler at runtime, either by using Runtime.exec(...) or the the JavaCompiler API. The latter approach is described in:

    • How do I programmatically compile and instantiate a Java class?

    and there are lots of other resources on the subject.

    However, your primary goal seems to be to check that your generators are generating correct Java code; e.g. as part of your application tests. For that, it would be simplest to off-load the problem to a shell script that uses javac to the compile the code with an appropriate classpath, checks the compiler’s return code, and greps the compiler output for error and warning messages.

    But … as you are probably aware … simply compiling the generated code doesn’t guarantee that it will be correct.


    I was thinking of using Class class to get information about the class.

    That won’t help. The Class class is only relevant for classes that have been successfully compiled and successfully loaded by the JVM. And even then it doesn’t tell you if there were syntax (or other) errors in the original code.

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

Sidebar

Ask A Question

Stats

  • Questions 541k
  • Answers 541k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It's much more simple than having to muck with actual… May 17, 2026 at 2:48 am
  • Editorial Team
    Editorial Team added an answer CFSTOREDPROC should have better performance for the same reason a… May 17, 2026 at 2:48 am
  • Editorial Team
    Editorial Team added an answer Have you confirmed that onRetainNonConfigurationInstance() is actually being called? I… May 17, 2026 at 2:48 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I wrote a little Java servlet that would dynamically generate an image button given
I have made a little app for signing up for an event. User input
I'm a beginner with C# so I made a little app, to figure out
I made this little Cocoa app with a WebView that displays Google Maps in
I made a little cocoa app that brings up an IKPictureTaker and saves a
I've got something happening with a little app that I made that I don't
I have been playing around with Template functions, and made a little logger program.
I made little jquery script for checking if input box value bigger than 5
Recently I made a little site and want to rewrite it using ASP.NET MVC.
I'm currently writing an app in Python and need to provide localization for it.

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.